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

How to use this in NextJS #18

Closed
gj1118 opened this issue Dec 25, 2022 · 5 comments · Fixed by #22
Closed

How to use this in NextJS #18

gj1118 opened this issue Dec 25, 2022 · 5 comments · Fixed by #22
Assignees
Labels
question Further information is requested

Comments

@gj1118
Copy link

gj1118 commented Dec 25, 2022

Hi,
This looks mighty impressive. However, when I try to use in NextJs, I am seeing the error message "document is not defined".

When I try dynamic importing it, the linter throws me this error

image

Thanks

@bvaughn
Copy link
Owner

bvaughn commented Dec 25, 2022

Can you share a repro with me (for the error)?

A link to a repository with instructions on how to run would be fine.

@bvaughn bvaughn added the question Further information is requested label Dec 25, 2022
@SCG82
Copy link

SCG82 commented Dec 26, 2022

const PanelGroup = dynamic(() => import('react-resizable-panels').then(({ PanelGroup }) => PanelGroup))
const Panel = dynamic(() => import('react-resizable-panels').then(({ Panel }) => Panel))

@bvaughn
Copy link
Owner

bvaughn commented Dec 26, 2022

Looks like there are some issues with server rendered auto-generated ids matching client-rendered ones. I think the new useId hook might be able to help here but I need to look.

@bvaughn
Copy link
Owner

bvaughn commented Dec 26, 2022

I think the most straight-forward fix here is to use useId for groups, panels, and resize handles if it's available and then just require user-injected ids for older versions of React. I think I have a pattern that works pretty well here now based on my local testing.

@bvaughn
Copy link
Owner

bvaughn commented Dec 26, 2022

So far asI can tell, PR #22 resolves this issue. (You didn't provide a runnable repro so I'm guessing a bit after making my own Next JS app to test.)

Fix released in v0.0.13

@bvaughn bvaughn closed this as completed Dec 26, 2022
bvaughn added a commit that referenced this issue Dec 26, 2022
* Use useId hook (when available) to generate ids for panels/groups/resize handles.
* Panel component no longer requires an id prop (falling back to useId if none is provided).
* PanelGroup component sets default style position: relative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants