-
Notifications
You must be signed in to change notification settings - Fork 43
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
Islands that use useRequestContext are unresponsive #96
Comments
Hi @BasWilson This might be a bug! @usualoma Could you investigate this matter? |
Hi @BasWilson Unfortunately, In island, there is nothing that can be returned from |
Ah I see, thought as much. But where would the exception be visible? See none thrown in server on client logs. |
I'd like to confirm, does this mean that we can't use I understand that we cannot refer to the Context value on the client. However, we can get the value from the Context on the server side. I think there are use cases where we want to use the value of the Context in Island components. Is it possible to render the value on the server only and pass the value to the client and not get an error? |
Let's see, if an application wants to use the following component, import { useState } from 'hono/jsx';
import { useRequestContext } from 'hono/jsx-renderer';
export default function Counter() {
const c = useRequestContext()
const [count, setCount] = useState(parseInt(c.req.query("c") ?? "0", 10))
return (
<div>
<p>Count: {count}</p>
<button onClick={() => {
setCount(count + 1)
}}>Increment</button>
</div>
)
} In island, I would like to see the following used import { useState } from 'hono/jsx';
export default function Counter({init}) {
const [count, setCount] = useState(init)
return (
<div>
<p>Count: {count}</p>
<button onClick={() => {
setCount(count + 1)
}}>Increment</button>
</div>
)
} // server component
import { useRequestContext } from 'hono/jsx-renderer';
import Counter from '../islands/counter.tsx';
export default () => {
const c = useRequestContext()
return <Counter init={parseInt(c.req.query("c") ?? "0", 10) />
} |
I believe this is impssible because it is not possible to identify "which value was retrieved, processed, and output" on the server component side. Do you have code for the island component that says "this component should work"? |
Sorry to take the time to explain. You are right, that is impossible. Plus, if we want to use a context value in the Island component, we should pass the value that way from the server side. For this issue, I think it is a good idea to throw an error if |
Hi @yusukebe I think it would be a little more convenient if the following were done, but I think it would be difficult to accomplish this without compromising performance and without using more black-magic methods.
As noted in the comments below, the client is currently throwing errors and can identify the error location, so I, for my part, would prefer no additional action at this time. |
@yusukebe Thank you! |
I think this can be closed. Thanks! |
What version of HonoX are you using?
0.1.5
What steps can reproduce the bug?
Create a basic island with the useRequestContext hook.
What is the expected behavior?
The count state should increment.
What do you see instead?
No increments.
Additional information
No response
The text was updated successfully, but these errors were encountered: