-
Notifications
You must be signed in to change notification settings - Fork 293
Fetching data
Haz edited this page May 2, 2017
·
10 revisions
In order to be able to fetch data on server side, ARc uses react-router-server
. You need to decorate your container with fetchState
and call this.props.done
.
For example:
import { fetchState } from 'react-router-server'
class ResourceListPageContainer extends React.Component {
componentWillMount() {
const { done } = this.props
this.props.readList(done)
}
render() {
return <ResourceListPage />
}
}
const mapDispatchToProps = dispatch => ({
readList: done => dispatch(resourceLisReadRequest({}, done, done))
})
const withDone = fetchState(null, actions => ({ done: actions.done }))
export default withDone(connect(null, mapDispatchToProps)(ResourceListContainer))
Special thanks to @kybarg and @protoEvangelion for helping to write this Wiki. Please, feel free to edit/create pages if you think it might be useful (also, see #33)