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

Can islands support shared state? #74

Open
aulneau opened this issue Feb 20, 2024 · 4 comments · Fixed by #80
Open

Can islands support shared state? #74

aulneau opened this issue Feb 20, 2024 · 4 comments · Fixed by #80
Labels
enhancement New feature or request

Comments

@aulneau
Copy link

aulneau commented Feb 20, 2024

Hi there! Really loving honox!

I'm experimenting with using it as a react renderer and am running into issues with islands sharing context or state. Specifically I'm trying to wrap some islands that use react query with a parent island that sets the query client context.

Should this be possible or am I misunderstanding now islands should behave?

Thanks so much!

@aulneau aulneau added the enhancement New feature or request label Feb 20, 2024
@yusukebe
Copy link
Member

Hi @aulneau

Thank you for using HonoX!

The sharing of states and variables between Islands is not supported. I knew there would be requests for it, but at first, we would not implement it.

We could look at that if you could create a minimal project doing what you want to archive with React Query, though I don't know if it can be done!

@aulneau
Copy link
Author

aulneau commented Feb 20, 2024

Sure thing, here is the repo: https://github.com/aulneau/honox-react-query

I think if islands can share state, this will be such a big feature! I have spent the last few days trying out a bunch of alternative jsx/react meta frameworks, and honox is the best by far! Ideally all islands would share the same client state/env, so things like useContext work

Happy to help in whatever way I can :)

provider.tsx
query.tsx
provider in renderer
query in index route

@aulneau
Copy link
Author

aulneau commented Feb 20, 2024

I've also noticed that islands specifically need export default function to work. I can't do a named export or a separate declaration and default export. Is that expected?

@yusukebe
Copy link
Member

yusukebe commented Feb 21, 2024

@aulneau

Thanks! I'll check it, and #80 might resolve the issue.

I've also noticed that islands specifically need export default function to work. I can't do a named export or a separate declaration and default export. Is that expected?

@usualoma suggests the PR #81 (but that is about unnamed default export, it may not be what you want)

@yusukebe yusukebe reopened this Feb 22, 2024
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

Successfully merging a pull request may close this issue.

2 participants