For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/react/Function.useState.md.
  • English
  • @lynx-js/react / useState

    Function: useState()

    useState(initialState)

    function useState<S>(initialState: S | () => S): [S, Dispatch<SetStateAction<S>>]

    Returns a stateful value, and a function to update it.

    Type Parameters

    Type Parameter
    S

    Parameters

    ParameterType
    initialStateS | () => S

    Returns

    [S, Dispatch<SetStateAction<S>>]

    Version

    16.8.0

    See

    https://react.dev/reference/react/useState

    Defined in

    .pnpm/@types+react@18.3.28/node_modules/@types/react/ts5.0/index.d.ts:1884

    useState()

    function useState<S>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>]

    Returns a stateful value, and a function to update it.

    Type Parameters

    Type ParameterDefault type
    Sundefined

    Returns

    [S | undefined, Dispatch<SetStateAction<S | undefined>>]

    Version

    16.8.0

    See

    https://react.dev/reference/react/useState

    Defined in

    .pnpm/@types+react@18.3.28/node_modules/@types/react/ts5.0/index.d.ts:1892

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.