Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds onEnter function to UserAuthWrapper #19

Merged
merged 2 commits into from
Feb 15, 2016
Merged

Adds onEnter function to UserAuthWrapper #19

merged 2 commits into from
Feb 15, 2016

Conversation

mjrussell
Copy link
Owner

Useful in server side rendering #17

@mjrussell
Copy link
Owner Author

@themouette this seems to work pretty well for onEnter, but Im not really happy with how it uses the query parameter on for the auth check but the history state for onEnter. Seems like this would be pretty annoying to have to check the state or query parameter depending on if the onEnter or Higher Order Component redirected. Thoughts?

@themouette
Copy link

That's great! Thanks a lot.

Seems like this would be pretty annoying to have to check the state or query parameter depending on if the onEnter or Higher Order Component redirected.

Indeed, maybe using the query parameter for both browser and server is the best strategy as it is available everywhere.

@@ -106,6 +106,14 @@ const UserAuthWrapper = (args) => {

return hoistStatics(UserAuthWrapper, DecoratedComponent)
}

wrapComponent.onEnter = (store, nextState, replace) => {
const replaceWithState = ({ pathname, query }) => replace({ pathname, state: query })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I read on the react-router doc, to use query string instead of state would be done by replacing previous line with:

const replaceWithState = ({ pathname, query }) => replace({ pathname, query })

@mjrussell
Copy link
Owner Author

Yeah I started with using the query key, but the tests on travis seemed to be failing to validate that the query got set (worked locally). Going to switch back to the query key and do a little more debugging. There's nothing from the React-Router docs that would expect it to not work that way.

@mjrussell
Copy link
Owner Author

well that works now, maybe the RR bump helped or just was a temporary travis issue.

mjrussell added a commit that referenced this pull request Feb 15, 2016
Adds onEnter function to UserAuthWrapper
@mjrussell mjrussell merged commit ad15490 into master Feb 15, 2016
@mjrussell mjrussell deleted the onEnter branch February 15, 2016 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants