Skip to content

Instantly share code, notes, and snippets.

@clarabstract
Last active June 15, 2017 22:48
Show Gist options
  • Select an option

  • Save clarabstract/dfa94d503638815cbf40a0d6e9b21afa to your computer and use it in GitHub Desktop.

Select an option

Save clarabstract/dfa94d503638815cbf40a0d6e9b21afa to your computer and use it in GitHub Desktop.
let DocumentConnector = connect((state, ownProps) => {
return {
document: lookupDocument(state, ownProps.documentId),
}
}, (dispatch) => {
// Note: this is actually the default behavior if mapPropsToDispatch is null
// I'm just including it here for clarity
return {dispatch}
}, ({document}, {dispatch}, {documentId}) => {
return {
children: <ViewComponent document={document} />,
sidebar: <Sidebar document={document} />,
title: document.title,
onDocumentUpdate(event) {
dispatch(updateDocument(documentId, event))
},
documentId,
};
})
<Route path="/document/:id" render={({id}) => <DocumentConnector(LayoutComponent) documentId={id} />} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment