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
Rendering message on React Server Component page load #409
Comments
Hi @ScreamZ, Example: (Javascript) // ServerComponent.js
// Importing the component using 'next/dynamic' so that its only be rendered on the client side, not server side.
const ClientComponet = dynamic(() => import("./ClientComponent.js"), {
ssr: false // When setting the SSR flag to false, the component is not pre-rendered on the server.
})
export default function ServerComponent() {
return (
// Application code.
<ClientComponent />
)
}
|
Yes thanks, but doing this way I still need to render an empty component, i cannot just use an hook isn't ? |
I am also creating a toast library (toast-ease@v0.0.1), you can have a look at that, though its still under development. (https://github.com/gurvirsinghbaraich/toast-ease) |
I would like your insight on a use case,
I'm using NextJS with RSC and I would like to display a message to a user arriving on the website only if it is logged.
Currently I ended up with this pattern, but sadly I have to render null, is there any way to proceed ? I used such pattern when hooks where not existing, but now we are supposed to use hooks, but using a custom hook with
use client
doesn't seems to work.Thanks
EDIT:
Humm, it seems complicated with server components when the URL change
useEffect
is played again. Not sure how to deal with my use case nowI guess this is a use case for a full client mode? But how? Was easier with page router 😅
Screen.Recording.2024-05-01.at.18.52.02.mov
The text was updated successfully, but these errors were encountered: