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

Add passing custom histories to match #2813

Merged
merged 1 commit into from
Jan 1, 2016
Merged

Add passing custom histories to match #2813

merged 1 commit into from
Jan 1, 2016

Conversation

timdorr
Copy link
Member

@timdorr timdorr commented Jan 1, 2016

Will make redux-simple-router integration more clear.

invariant(
location,
'match needs a location'
)

let history = createMemoryHistory(options)
history = history ? history : createMemoryHistory(options)
Copy link
Member Author

Choose a reason for hiding this comment

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

My brain is slow. Certainly there's a better way to do this?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't do this in the assignment because you need options. Just history || createMemoryHistory(options) is the best I can think of.

@taion
Copy link
Contributor

taion commented Jan 1, 2016

Can you elaborate a bit on what this is for?

@timdorr
Copy link
Member Author

timdorr commented Jan 1, 2016

If you want to customize the history used in match in any way, you can't. For libraries that integrate with history, this means they can only do so after-the-fact in the callback and may miss history events occurring during the transition manager's matching.

@taion
Copy link
Contributor

taion commented Jan 1, 2016

How does that come up? By assumption if you're running this on the browser, the matching has already completed on the server side, so the client-side match should be a no-op, no?

@ryanflorence
Copy link
Member

Seems fine to me, we take whatever history you give us in Router as well.

@timdorr
Copy link
Member Author

timdorr commented Jan 1, 2016

@taion In the case of Redux, you will be passing along your state to the browser to let it continue from where the server left off. So, if you don't have history synced up to redux before you start matching, you will likely be missing some important state from the routing when crossing that divide.

@timdorr
Copy link
Member Author

timdorr commented Jan 1, 2016

@ryanflorence Cool. I'll merge this in. This just keeps the API surface area sane between the two entry points.

timdorr added a commit that referenced this pull request Jan 1, 2016
Add passing custom histories to match
@timdorr timdorr merged commit 8ca933e into master Jan 1, 2016
@timdorr timdorr deleted the match-history branch January 1, 2016 18:20
@taion
Copy link
Contributor

taion commented Jan 1, 2016

Oh, that's cool, makes sense. Thanks.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 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.

None yet

3 participants