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

Creating HasIslands component with useRequestContext in react-renderer #127

Open
yossydev opened this issue Mar 21, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@yossydev
Copy link
Contributor

yossydev commented Mar 21, 2024

What is the feature you are proposing?

I would like to create a component called HasIslandWithReactRenderer so that island will work even when using react-renderer.

Currently there is only a HasIsland component that supports the hono/jsx context, so if I use reactRenderer I get an error: RequestContext is not provided.

For your information, I made it in my repository and it worked, how about you?

Reference implementation:

import { useRequestContext } from "@hono/react-renderer";

const HasIslandWithReactRenderer: FC<PropsWithChildren> = ({ children }) => {
  const c = useRequestContext();
  return <>{c.get(IMPORTING_ISLANDS_ID) ? children : <></>}</>;
};
@yossydev yossydev added the enhancement New feature or request label Mar 21, 2024
@yusukebe
Copy link
Member

Hi @yossydev

That will be very helpful for React-users! But honox/server should not export HasIslandWithReactRenderer as the same as HasIsland.

I'm planning to make the helper methods for using React as a renderer like this:

import { createClient } from 'honox/react/client'

Or creating a package:

import { createClient } from '@honox/react/client'

So, it's a good idea to make HasIslandWithReactRenderer or simply HasIsland in honox/react or @honox/react.

However we're in the process of designing it now, so we can't get started right away.

@yossydev
Copy link
Contributor Author

yossydev commented Mar 23, 2024

Thank you for your comment! @yusukebe
I understand! Someone wanted to use shadcn/ui in honox, but shadcn/ui depends on react, so I was touching things up to make the development experience there better!

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

No branches or pull requests

2 participants