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

[Bug] Warning: Cannot update a component when navigating #2354

Open
MaksimLavrenyuk opened this issue Apr 8, 2024 · 1 comment
Open

[Bug] Warning: Cannot update a component when navigating #2354

MaksimLavrenyuk opened this issue Apr 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MaksimLavrenyuk
Copy link

Summary

When using the Server Hybrid (Server + Client Rendering) scheme for next.js, we get warning when navigating.
The error occurs because of using the useGrowthBookSSR hook.

You can repeat with an example from the repository: https://github.com/growthbook/examples/tree/main/next-js

Click the Server Hybrid (Server + Client Rendering) link on the home page (/server-hybrid).
On the first transition we will see the warning, on subsequent transitions it will not be there.

bug-1.mov

Expected Behavior

Navigation does not create a warning.

Current Behavior

Using the Server Hybrid scheme (Server + Client Rendering), we get a navigation error.

server-hybrid.tsx:26 Warning: Cannot update a component (`GrowthBookProvider`) while rendering a different component (`ServerHybridPage`). To locate the bad setState() call inside `ServerHybridPage`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
    at ServerHybridPage (webpack-internal:///./pages/server-hybrid.tsx:16:11)
@MaksimLavrenyuk MaksimLavrenyuk added the bug Something isn't working label Apr 8, 2024
@bttf
Copy link
Collaborator

bttf commented Apr 26, 2024

@MaksimLavrenyuk We recently updated our next.js example in our growthbook/examples repo. This problem was addressed in our hybrid implementation. Mind taking a look and letting us know if it helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants