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

ResizeObserver is not defined #226

Open
aspnetde opened this issue Jul 31, 2024 · 3 comments
Open

ResizeObserver is not defined #226

aspnetde opened this issue Jul 31, 2024 · 3 comments

Comments

@aspnetde
Copy link

When adding the markdown editor to a current NextJs client component, building fails with a rather generic ReferenceError: ResizeObserver is not defined.

I don't have time for a reproduction test right now (sorry), but a quick workaround is using the polyfill as described here: https://stackoverflow.com/a/78560100/271150

@jaywcjlove
Copy link
Member

@aspnetde You might need to move it to client-side rendering instead of server-side. Add 'use client'; at the top of the code.

@joelrb
Copy link

joelrb commented Sep 10, 2024

@aspnetde You might need to move it to client-side rendering instead of server-side. Add 'use client'; at the top of the code.

I have this issue. Both the parent and the component have "use client"; at the top of code. First time to use Markdown.

<MarkdownEditor value={description} enablePreview enableScroll height="600px" className="w-full" onChange={(value, viewUpdate) => setDescription(value)} />

Screenshot 2024-09-10 164418

@joelrb
Copy link

joelrb commented Sep 10, 2024

Indeed, adding this to the component seems to have fixed the issue.

import ResizeObserver from 'resize-observer-polyfill';
global.ResizeObserver = ResizeObserver;

When adding the markdown editor to a current NextJs client component, building fails with a rather generic ReferenceError: ResizeObserver is not defined.

I don't have time for a reproduction test right now (sorry), but a quick workaround is using the polyfill as described here: https://stackoverflow.com/a/78560100/271150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants