How to use useState Hook ? #1819
-
How to use useState Hook in Hydrogen.... I couldn't find clear guidence when to use useState Hook and it's limitations |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Have you given it a try? What kind of errors are you seeing? :) Yes, Your app will always have a top-level server component: See this doc for more details: https://shopify.dev/custom-storefronts/hydrogen/framework/react-server-components |
Beta Was this translation helpful? Give feedback.
Have you given it a try? What kind of errors are you seeing? :)
Yes,
useState
can only be used in client components. Yes, client components are rendered by server components.Your app will always have a top-level server component:
App.server.jsx
. That component, or any child server component, may render a client component which may invokeuseState
.See this doc for more details: https://shopify.dev/custom-storefronts/hydrogen/framework/react-server-components