@lynx-js/react / useReducer
An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
| Type Parameter |
|---|
R extends ReducerWithoutAction<any> |
I |
| Parameter | Type |
|---|---|
reducer | R |
initializerArg | I |
initializer | (arg: I) => ReducerStateWithoutAction<R> |
[ReducerStateWithoutAction<R>, DispatchWithoutAction]
16.8.0
https://react.dev/reference/react/useReducer
.pnpm/@types+react@18.3.11/node_modules/@types/react/ts5.0/index.d.ts:1896
An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
| Type Parameter |
|---|
R extends ReducerWithoutAction<any> |
| Parameter | Type |
|---|---|
reducer | R |
initializerArg | ReducerStateWithoutAction<R> |
initializer? | undefined |
[ReducerStateWithoutAction<R>, DispatchWithoutAction]
16.8.0
https://react.dev/reference/react/useReducer
.pnpm/@types+react@18.3.11/node_modules/@types/react/ts5.0/index.d.ts:1912
An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
| Type Parameter |
|---|
R extends Reducer<any, any> |
I |
| Parameter | Type |
|---|---|
reducer | R |
initializerArg | I & ReducerState<R> |
initializer | (arg: I & ReducerState<R>) => ReducerState<R> |
[ReducerState<R>, Dispatch<ReducerAction<R>>]
16.8.0
https://react.dev/reference/react/useReducer
.pnpm/@types+react@18.3.11/node_modules/@types/react/ts5.0/index.d.ts:1930
An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
| Type Parameter |
|---|
R extends Reducer<any, any> |
I |
| Parameter | Type |
|---|---|
reducer | R |
initializerArg | I |
initializer | (arg: I) => ReducerState<R> |
[ReducerState<R>, Dispatch<ReducerAction<R>>]
16.8.0
https://react.dev/reference/react/useReducer
.pnpm/@types+react@18.3.11/node_modules/@types/react/ts5.0/index.d.ts:1946
An alternative to useState.
useReducer is usually preferable to useState when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch down instead of callbacks.
| Type Parameter |
|---|
R extends Reducer<any, any> |
| Parameter | Type |
|---|---|
reducer | R |
initialState | ReducerState<R> |
initializer? | undefined |
[ReducerState<R>, Dispatch<ReducerAction<R>>]
16.8.0
https://react.dev/reference/react/useReducer
.pnpm/@types+react@18.3.11/node_modules/@types/react/ts5.0/index.d.ts:1971