Skip to content

How to use useState Hook ? #1819

Answered by davidhousedev
ishub-mobi asked this question in Help
Discussion options

You must be logged in to vote

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 invoke useState.

See this doc for more details: https://shopify.dev/custom-storefronts/hydrogen/framework/react-server-components

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ishub-mobi
Comment options

@davidhousedev
Comment options

@ishub-mobi
Comment options

Answer selected by juanpprieto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants