diff --git a/packages/react/test/snippets/suspense2.mdx b/packages/react/test/snippets/suspense2.mdx index 313927ae..0a8d7ccd 100644 --- a/packages/react/test/snippets/suspense2.mdx +++ b/packages/react/test/snippets/suspense2.mdx @@ -37,8 +37,10 @@ function Child() { + ) +} + +function App() { + const [userId, setUserId] = useState(1) + const { promise, data } = useStuff(userId) + const subscribe = useMemo(() => () => () => {}, []) + + let rerender = useState()[1] + + console.log('rendering...', data) + if (!data) { + throw promise + } + + const user = useSyncExternalStore(subscribe, () => data) + console.log('returning stuff...', user) + + // can be replaced with + // const user = api.use(userId); + + return ( +
+
+ +

Click to see user's details

+
Button will be disabled when pending
+
+ {userIds.map(u => ( + + ))} +
+
+ +
+ User {user.username} details +
{JSON.stringify(user, null, 4)}
+
+
+ ) +} + +function Root() { + return ( + + + + ) +} +```