Skip to content

Conversation

elasim
Copy link

@elasim elasim commented Jul 4, 2016

I changed onEnter callback to inject props.

onEnter(nextState : object, replace : function, ?callback : function(error, redirectInfo, asyncProps))

second parameter will not works right now. I added this parameter to keep consistency.
It will look like 'match' functions callback.
maybe we can use this parameter as alternative of 'replace' function
third parameter will passing into container component.

Here is example

<Route path="test" component={TestContainer} onEnter={(nextState, replace, callback) => {
  callback(null, null, { injectProps: 'hello world!' });
}}>

TestContainer will have injectProps,

@taion
Copy link
Contributor

taion commented Jul 4, 2016

onEnter is not the right place for this sort of logic – this should go in a router middleware like async-props or react-router-relay.

@timdorr
Copy link
Member

timdorr commented Jul 4, 2016

Right. This can be done with a middleware.

@timdorr timdorr closed this Jul 4, 2016
@elasim
Copy link
Author

elasim commented Jul 4, 2016

Ah, I see. Thanks to review. I was have to read document better carefully.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants