-
Notifications
You must be signed in to change notification settings - Fork 293
Fetching data
Michał Mrozowski edited this page Sep 26, 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 { withDone } from 'react-router-server'
class ResourceListContainer extends React.Component {
componentWillMount() {
this.props.readList()
}
render() {
return <ResourceList />
}
}
const mapDispatchToProps = (dispatch, { done }) => ({
readList: () => dispatch(resourceListReadRequest({})).then(done, 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)