-
Notifications
You must be signed in to change notification settings - Fork 216
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 scroll-behavior
capability
#261
Comments
Or maybe this library shouldn't incorporate import useScroll from 'react-router-scroll'
import { RouterContext } from 'react-router'
// Add `scroll-bevahiour` for scroll position management
const RoutingContext = (props) =>
{
// https://github.com/taion/react-router-scroll/blob/master/src/index.js
return useScroll().renderRouterContext(<RouterContext {...props}/>, props)
}
<ReduxRouter RoutingContext={RoutingContext}/> |
Yep, would be better. You could also formulate a stackoverflow question and answer it yourself. This way it can be found more easily. |
Wouldn't something like this be better? import { applyRouterMiddleware } from 'react-router'
const RouterContext = applyRouterMiddleware(useScroll());
<ReduxRouter RoutingContext={RouterContext}/> |
Oh, yes, Julian is a @perrin4869 I've just tested your code and it seems to work. I agree that it can be considered a better solution. |
@halt-hammerzeit I'm not really a contributor to |
You can add a section in the README saying that if a user wants
scroll-behavior
then they should first install it (react-router-scroll
hasscroll-behavior
bundled)And then pass
scrollBehavior={true}
prop to<ReduxRouter/>
ReduxRouter.js
I tested this code and it works as intended (waits for page to fetch data asynchronously, and then does the scrolling thing).
If someone tries using bare
scroll-behavor
usingcreateHistory
when creating Redux store then it won't work: the page scroll will be laggy when navigating through pages, not waiting for page data to load. This method I came up with solves the issue.The text was updated successfully, but these errors were encountered: