-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Server side rendering causes the layout to shift when loading #85
Comments
Hi @cristianpjensen! You could try to wrap your component with 'next/dynamic' it should be a safe way to get it working without flickering |
Good question. Maybe if you stored the group layout somewhere that was accessible to both the client and server, then used those sizes to pre-load the server-rendered content...this could work, although it would still require a change to To be honest, server-rendering is not a use case I have, so I'd require your help on figuring that one out. |
This works! (for others reading this that have the same problem, you should set the I also think it is important for SEO that the content is loadable on the server.
Something like this would be perfect, but I do not know whether such a storage exists in NextJS. Maybe cookies? |
Yes, cookies are accessible on the server via An even better idea is if a user could provide getter and setter functions for these values. Zustand also provides such an option. This would give users a lot more customizability and it could just default to using local storage. |
I like the |
Okay, I think that's a nice simplifying suggestion for external persistence. I've added an optional |
Just published as v0.0.34 Full release notes here: |
I'm using this with the new NextJS app directory in a client component and it does seem to fix the layout issue, although I get an error on the SSR step as localStorage is not defined - which is to be expected:
The panel group is set up like this: <PanelGroup direction="horizontal" storage={localStorage}> I'd rather not dynamically import the whole group with SSR disabled, so do you know of a way around this? The lack of localStorage on the server doesn't seem to actually cause a problem, at least not an obvious one. Only the error which I'd rather not have. I'm also not that experienced with NextJS so this could just be a me problem. |
@bchilcott I’m out at the moment, but would you file a new issue about this? I can probably wrap the |
Opened #144 - I'll add a repro if I get a chance later. |
I am using NextJS and at the start (after a refresh), the panels start in their default configuration (so not whatever the user had before). Then it quickly shifts to the user's intended position (within a couple ms).
It looks like this:
I feel like the panel should be client side rendered, but I do not want the content of the panels to be client side rendered. Is there anything that can be done against this? I do not have a lot of experience with NextJS, so there is probably an easy solution I am not seeing.
The text was updated successfully, but these errors were encountered: