# Type alias SetStateAction<S>

SetStateAction<S>: S | ((prevState) => S)

The instruction passed to a Dispatch function in useState to tell React what the next value of the useState should be.

Often found wrapped in Dispatch.

#### Type Parameters

- S

  The type of the state.

#### Type declaration

- - (prevState): S

  - #### Parameters

    - prevState: S

    #### Returns S

#### Example

    // This return type correctly represents the type of
    // `setCount` in the example below.
    const useCustomState = (): Dispatch<SetStateAction<number>> => {
      const [count, setCount] = useState(0);

      return setCount;
    }

- Defined in common/temp/node_modules/.pnpm/@types+react@18.3.3/node_modules/@types/react/index.d.ts:1823