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.

next-redux-wrapper usage slows down route change

See original GitHub issue

Describe the bug

Whenever I use next-redux-wrapper, changing routes starts to get really slow.

export const getServerSideProps: GetServerSideProps<I18nProps<MyLocale>> = getStore((store) => async (ctx) => {
// ...
  store.dispatch(setFeatureFlags(flags));
// ...
  store.dispatch(updateDevice(getSelectorsByUserAgent(ctx.req.headers["user-agent"])));
  return ...;
});

With the code above, whenever I change routes, it takes around 10s to change on dev and 5s on prod. If I remove it, it becomes instant, like milliseconds.

To Reproduce

The code is proprietary, I can’t fork or clone it.

Steps to reproduce the behavior:

Just use this library with some dependencies like usedapp, or theming, or any UI lib. Check how long it takes to change routes. Remove it, and you’ll see the difference.

Expected behavior

Using redux shouldn’t impact the app routing load time.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 6]

Additional context

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
kirill-konshincommented, Aug 12, 2022

I can release it, it’s been in beta for quite some time.

3reactions
roshaninetcommented, May 29, 2022

hi , i had this problem too, you can use 8.0.0-rc.1 instead of 7.0.5 there is some changes

for create store you must use configureStore

const makeStore = () =>
    configureStore({
        reducer: appReducer,
        devTools: true,
    });

export const wrapper = createWrapper(makeStore, {debug: false});

and in _app.js:

const App = ({Component, ...rest}) => {
    const {store, props} = wrapper.useWrappedStore(rest);
    return (
        <Provider store={store}>
                <Component {...props.pageProps} />
        </Provider>
    )
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

nextjs get slow on route change in react 18 and redux(legacy ...
the issue is: when we use react 18.0.0 to 18.2.0 the app takes around 7 sec on production to change the route. on...
Read more >
Bountysource
next -redux-wrapper usage slows down route change.
Read more >
next-redux-wrapper - npm
Redux wrapper for Next.js. Latest version: 8.0.0, last published: 4 months ago. Start using next-redux-wrapper in your project by running ...
Read more >
Redux Essentials, Part 6: Performance and Normalizing Data
How to create memoized selector functions with createSelector; Patterns for optimizing component rendering performance; How to use ...
Read more >
What's new in Next.js 13, and what do they really do?
You use folders to define routes, and special files with reserved names ... Your mental model of how components work in Next.js has...
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