logo
down
shadow

How to populate datasource for listview using api response in react native?


How to populate datasource for listview using api response in react native?

Content Index :

How to populate datasource for listview using api response in react native?
Tag : development , By : CrookedNumber
Date : January 12 2021, 08:33 AM

To fix this issue My Api returns me a response exactly like the const "devices" defined below. If i don't call the api, i am getting the listview properly populated with single row of data, but if i populate the datasource using Api response, i am getting empty 160 rows. , Try this:
dataSource: this.state.dataSource.cloneWithRows(JSON.parse(response.getB‌​odyString()))

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

React Native: ListView renders before dataSource being set


Tag : javascript , By : Ben Kohn
Date : March 29 2020, 07:55 AM
it should still fix some issue You can use the componentWillMount-hook instead of the componentDidMount.
Using the first, sets it before the render. The latter fires after the component is rendered for the first time.
class Courses extends Component {
    /* ... */

    componentDidMount() {

        // Will fetch your data asynchronously
        this.props.getCourses(this.props.users);

    }

    // This hook gets the new props passed. Old props are
    // still available in this.props
    componentWillReceiveProps(newProps) {

        const courses = newProps.courses.courses[this.props.user]
        this.setState({
            dataSource: this.state.dataSource.cloneWithRows(courses),
            dataLoaded: courses.length
        })

    }

    /* ... */
}

react native ListView datasource not updating


Tag : development , By : Mighty Mac
Date : March 29 2020, 07:55 AM
Any of those help So after a lot of reading and changes the listview is now updating. According to this post
Changes the ds declaration to:
this.ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
changeisCompleted=(rowData,rowId)=>{

           var newDs = [];
           newDs = this.state.todoListArray.slice();
           newDs[rowId].isCompleted =!newDs[rowId].isCompleted;


           this.setState({
                  dataSource: this.ds.cloneWithRows(this.state.todoListArray),
                  todoListArray:newDs
               })


            }

React Native: ListView.DataSource is not updating


Tag : react-native , By : sep
Date : March 29 2020, 07:55 AM
around this issue In your code, you only set your dataSource in contructor of FormativeRevisionList, this mean FormativeRevisionList will only render the given movies when your first render it.
To render new list after you press Get Topics button , you need to set the dataSource again when it receive new props, this can be achieve by setting it in FormativeRevisionList componentWillReceiveProps
  componentWillReceiveProps(nextProps) {
    if (nextProps.movies !== this.props.movies) {
      this.setState({
        dataSource: this.state.dataSource.cloneWithRows(nextProps.movies)
      })
    }
  }

Can't update dataSource with ListView on React-Native


Tag : javascript , By : Mike
Date : March 29 2020, 07:55 AM
With these it helps Managed to fix it with one of the previous answers listed here with a slight tweak:
 _getCoinData() {
    getCryptocurrencyData().then(function(result) {

        const ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
        this.setState({
            dataSource: ds.cloneWithRows(result),
            jsonData: result
        });

        console.log('!!!', this.state.jsonData);
    }.bind(this))
}

React-native ListView DataSource not updating


Tag : node.js , By : DonMac
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How do I create an HTML anchor in a FogBugz wiki page?
  • Sleep from within an Informix SPL procedure
  • License Models
  • Rational Purify failing to jump to memory leaks
  • Telligent's Community Server
  • Do people use the Hungarian Naming Conventions in the real world?
  • Memcached chunk limit
  • How do you pull the URL for an ASP.NET web reference from a configuration file in Visual Studio 2008?
  • How to add CVS directories recursively
  • Web App Beta
  • Virtual machine supporting multiple displays
  • LINQ to SQL strings to enums
  • How do I configure eclipse (zend studio 6) to hint and code complete several languages?
  • Recommended Fonts for Programming?
  • Automating VMWare or VirtualPC
  • How do I use more than one OpenID?
  • Domain Specific Language resources
  • Vista or XP for Dev Machine
  • Where can I get the Windows Workflow "wca.exe" application?
  • How to learn ADO.NET
  • What is a good barebones CMS or framework?
  • What's the Developer Express equivalent of System.Windows.Forms.LinkButton?
  • Is it acceptable for invalid XHTML?
  • Anyone soloing using fogbugz?
  • Using MBUnit in TeamCity
  • How to setup a crontab to execute at specific time
  • Linking two Office documents
  • How can I detect if a browser is blocking a popup?
  • Apply filter to t-foreach
  • Lotus Notes convert formula to agent
  • Problem with configuration of odoo for working with pycharm
  • Unexpected number of arguments when calling EM_JS function
  • What does the function state_fidelity() do in Qiskit?
  • Azure function with IoT Hub trigger get send device
  • Cluster similar words using word2vec
  • Add elements into an array then find distinct,
  • Angular8 - error TS2304: Cannot find name
  • Manually polling streams in future implementation
  • How do you perform receipt validation for Android on Xamarin Forms
  • What is the rule behind instruction count in Intel PIN?
  • How to draw some text when click a button in wxWidgets?
  • Restrict entity types in Spacy NER
  • How to animate CN1 Slider progress on load
  • Issue with bwa mem process not running on all output files from previous process
  • Delete videos from playlist using YouTube API
  • How to restart the Hyperledger Composer Playground locally
  • How to configure email alerts in Zabbix Server?
  • Simulator is not working for smart home action with all configured session
  • How parse data using join on Objection.js
  • Assign an array to a property in a Chapel Class
  • Netlogo: How can I obtain the accumulate value in Netlogo?
  • Why does gmail API when using history.list method send message ids without the field what action has been preformed on t
  • How to run an append query in ms access vba as part of a transaction
  • Wrong dates shown in Jekyll-based blog
  • How to concatenate two document lists in a webMethods flow service?
  • How to properly set up a site map addition in a customization project
  • IBM Content Collector error calling external Web Service
  • Is (0*1*)* equal to (0 | 1)*?
  • How do I configure phpMyAdmin to start with a blank sql query from the SQL tab?
  • "Objects are not valid as a React child" Redux error when conditionally connecting a component?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com