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

fix: react server component support #16

Merged
merged 1 commit into from
Dec 13, 2023
Merged

Conversation

remidej
Copy link
Contributor

@remidej remidej commented Dec 12, 2023

What does it do?

  • Adds a "use client" directive to the BlocksRenderer component
  • Updates the pack-up plugin with a new plugin so that the custom directive doesn't get stripped. Solution from this comment, also used by react query

Why is it needed?

To prevent React from running these components on the server, as they require client-only APIs. See #10

I first tried to offer proper server component support by removing the use of React context. It made the DX quite a bit worse with lots of prop drilling. But it also wasn't enough as we're also using useRef, so I chose to go client-only instead.

How to test it?

Create a Next app with the app router, import and use the renderer, it shouldn't throw an error anymore.

Related issue(s)/PR(s)

Fixes #10

@remidej remidej added the pr: fix Bug fix label Dec 12, 2023
@remidej remidej self-assigned this Dec 12, 2023
Copy link
Contributor

@joshuaellis joshuaellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☃️

@remidej remidej merged commit 9d7f3a2 into main Dec 13, 2023
2 checks passed
@remidej remidej deleted the fix/server-component-support branch December 13, 2023 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat]: Mark renderer with "use client" to be used in Server Components
2 participants