bertho-zero / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using react, redux, express and feathers
https://react-hot-example.herokuapp.com/
MIT License
636 stars 171 forks source link

comparing location properly with pathname and search #512

Closed p-rk closed 5 years ago

p-rk commented 5 years ago

Bug fix: Equality check for the object to object won't work Checking with the pathname and search in nextProps and props

bertho-zero commented 5 years ago

I see the same issue: https://github.com/bertho-zero/react-redux-universal-hot-example/blob/b7a97ea9b34040db263dea5b3ef24ec539a0391c/src/containers/App/App.js#L66-L72

For here I think a comparison of location.pathname is enough.

p-rk commented 5 years ago

@bertho-zero yeah comparing just pathname is enough only when we don't have any query parameters in the URL but in case if someone adding query params dynamically (pagination example) then it would cause an issue.

Example: For instance, we have pagination then URL's will be like

https://example.com/?page=1 https://example.com/?page=2

Both are two different URLs and in this case, it causes the issue when the user/client navigates to page 2 and it will be at the same scroll position.

bertho-zero commented 5 years ago

On the doc they only compare the object: https://reacttraining.com/react-router/web/guides/scroll-restoration/scroll-to-top

p-rk commented 5 years ago

Need to check once. I will raise a PR if I find some ambiguity in restoring the scroll position. Right now I can't able to check.