Last active
July 21, 2023 06:45
-
-
Save nickserv/3c7bf45621a0edc6ac7ec3f2941dd076 to your computer and use it in GitHub Desktop.
RSC render JSX using server action from client component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use server"; | |
export async function hello() { | |
return <h1>Hello, world!</h1>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import { ReactNode, useEffect, useState } from "react"; | |
import { hello } from "./actions"; | |
export default function Home() { | |
const [jsx, setJsx] = useState<ReactNode>(); | |
useEffect(() => setJsx(hello()), []); | |
return jsx; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useEffect is what I was missing. I was getting an infinite loop without it.