Skip to content
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))
Clone this wiki locally