-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.d.ts
24 lines (23 loc) · 776 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Dispatch, SetStateAction } from 'react'
/**
* Takes in an object of initial state and returns an array containing
* three elements – `state`, `setState` and `setters`.
*
* `state` is an object that contains the current state of the component.
*
* `setState` is a multi-action dispatcher function that takes in a new state object.
*
* `setters` is an object that contains composed dispatchAction functions for each state property.
*
* @see https://github.com/whizkydee/react-multi-state#-usage
*/
export default function useMultiState<
T extends { [key: string]: any },
U extends Partial<T>
>(
initialState: T
): [
T,
((newState: (prevState: T) => U) => void) & ((newState: U) => void),
{ [key: string]: Dispatch<SetStateAction<unknown>> }
]