question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new react-router applyRouterMiddleware method

See original GitHub issue

Hi,

Just wondering, how the code would be changed with the new applyRouterMiddleware method from react-router.

Currently in the example we have

<Router render={(props) => <ReduxAsyncConnect {...props}/>} history={browserHistory}>

Thinking we should have something like

function useReduxConnect() { return { renderRouterContext: (child, props) => ( <ReduxAsyncConnect {...props} /> ) }; }

and then

<Router render={applyRouterMiddleware(useReduxConnect()} />} history={browserHistory}>

But not really sure.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
AVVScommented, May 7, 2016

I’ll add tests & example, you can track progress here:

https://github.com/makeomatic/redux-connect/tree/feat/applyRouterMiddleware

2reactions
AVVScommented, May 8, 2016

Copying here for lazy people:

@mmahalwy this looks pretty good without any need to handle {child}. I will try to get some code in to get this use-case working as well, but if not - this solution does work

const component = (
  <Router
    render={(props) => (
      <ReduxAsyncConnect
        {...props}
        helpers={{client}}
        filter={item => !item.deferred}
        render={applyRouterMiddleware(useScroll())}
      />
    )}
    history={history}
    routes={getRoutes(store)}
  />
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 5 react-router Code Examples - Snyk
To help you get started, we've selected a few react-router examples, based on popular ways it is used in public projects. Secure your...
Read more >
React router scrolls new page down - Stack Overflow
React Router does not include scroll state management starting in version 2.0.0. The recommended approach is to decorate the router with ...
Read more >
useHistory hook - React Router: Declarative Routing for React.js
The useLocation hook returns the location object that represents the current URL. You can think about it like a useState that returns a...
Read more >
JavaScript react-router applyRouterMiddleware Examples
JavaScript applyRouterMiddleware - 6 examples found. These are the top rated real world JavaScript examples of react-router.applyRouterMiddleware extracted ...
Read more >
Ultimate React Router v6 Guide
In our case we obviously want to render the /books/new route so React Router will select that route for us. The actual way...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found