Comments (2)
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.
@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)
- Add basic libraries
- Usage of Dimensions
- Unable to test HOT 1
- Add absolute path import to app, test and eslint
- Add flow
- Need Markdown Support
- Resolve csrf support issue HOT 3
- Add react-native-material-kit
- Cannot read property style of undefined HOT 1
- Add SSL certificate HOT 1
- Reduce action creator boilerplate HOT 2
- Explain how initialState is used? HOT 3
- Replace redux-thunk with redux-saga
- ES6 fat arrow functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactrails-react-native-client.