This document covers the details of a component that needs to fetch required data before rendering. In our imaginary app we're using react, redux, and react-router. We're covering the specific use-case of a detail page that gets its id
from the URL.
- URL contains an ID, it is matched by a route like
<Route path="/detail/:id" component={View} />
, which renders our<View />
- The
<View />
component receivesmatch
in props. Thematch
prop contains the ID inmatch.params.id
. - The
<View />
component renders some<MyContainer id={match.params.id} />
component with anid
prop. - The
<MyContainer id={match.params.id} />
container selects values from the state as props and passes them to the wrapped<My />
component. - When
<My />
component's lifecycle encounterscomponentWillMount
orcomponentWillReceiveProps
, it calls anonBeforeRender
function (passed in frommapDispatchToProps
by<MyContainer />
) - Then `` dispatches a