Coder Social home page Coder Social logo

Comments about reactrails-react-native-client HOT 2 OPEN

shakacode avatar shakacode commented on June 26, 2024
Comments

from reactrails-react-native-client.

Comments (2)

justin808 avatar justin808 commented on June 26, 2024

We should fetch the data in componentDidMount

https://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount

Because we don't want a race condition between render and loading. We also should have a spinner while we're waiting for the data to come back.

from reactrails-react-native-client.

badnorseman avatar badnorseman commented on June 26, 2024

@alleycat-at-git

I was thinking adding these statements to CommentsContainer and let it control data to CommentsComponent. We would also need to initialize the action fetch data from Container rather than inside Component. What do you think?

 componentDidMount() {
    this.setState({
      dataSource: this.state.dataSource.cloneWithRows(this.props.customer.behaviors || [])
    })
  }
  componentWillReceiveProps(nextProps) {
    this.setState({
      dataSource: this.state.dataSource.cloneWithRows(nextProps.customer.behaviors || [])
    })
  }

I used different approaches for ListView, but the datasource definition is usually only set once in the component. I tend to define datasource in state.

this. state = { datasource: new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 }) }

When I use it as shown above.

Beforehand, I had this pattern in the Component, but I am thinking that it could be in Container instead and remove state from the component.

from reactrails-react-native-client.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.