Skip to content
Haz edited this page May 7, 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 ResourceListContainer extends React.Component {
  componentWillMount() {
    this.props.readList()
  }

  render() {
    return <ResourceList />
  }
}

const mapDispatchToProps = (dispatch, { done }) => ({
  readList: () => dispatch(resourceLisReadRequest({}, done, done))
})

const withDone = fetchState(null, actions => ({ done: actions.done }))

export default withDone(connect(null, mapDispatchToProps)(ResourceListContainer))
Clone this wiki locally