Skip to main content

Function: useURLState()

A hook to manage a state variable that is also stored in the URL.

Param

The name of the key in the URL. If empty, then the hook behaves like useState.

Param

The default value of the state variable, or the params object.

useURLState(key, defaultValue)

function useURLState(key: string, defaultValue: number): [number, React.Dispatch<React.SetStateAction<number>>]

A hook to manage a state variable that is also stored in the URL.

Parameters

ParameterType
keystring
defaultValuenumber

Returns

[number, React.Dispatch<React.SetStateAction<number>>]

Param

The name of the key in the URL. If empty, then the hook behaves like useState.

Param

The default value of the state variable, or the params object.

Defined in

src/lib/util.ts:248

useURLState(key, valueOrParams)

function useURLState(key: string, valueOrParams: number | URLStateParams<number>): [number, React.Dispatch<React.SetStateAction<number>>]

A hook to manage a state variable that is also stored in the URL.

Parameters

ParameterType
keystring
valueOrParamsnumber | URLStateParams<number>

Returns

[number, React.Dispatch<React.SetStateAction<number>>]

Param

The name of the key in the URL. If empty, then the hook behaves like useState.

Param

The default value of the state variable, or the params object.

Defined in

src/lib/util.ts:252