Jesus sucks
This commit is contained in:
20
backend/frontend/node_modules/@restart/hooks/cjs/useStateAsync.d.ts
generated
vendored
Normal file
20
backend/frontend/node_modules/@restart/hooks/cjs/useStateAsync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
export type AsyncSetState<TState> = (stateUpdate: React.SetStateAction<TState>) => Promise<TState>;
|
||||
/**
|
||||
* A hook that mirrors `useState` in function and API, expect that setState
|
||||
* calls return a promise that resolves after the state has been set (in an effect).
|
||||
*
|
||||
* This is _similar_ to the second callback in classy setState calls, but fires later.
|
||||
*
|
||||
* ```ts
|
||||
* const [counter, setState] = useStateAsync(1);
|
||||
*
|
||||
* const handleIncrement = async () => {
|
||||
* await setState(2);
|
||||
* doWorkRequiringCurrentState()
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param initialState initialize with some state value same as `useState`
|
||||
*/
|
||||
export default function useStateAsync<TState>(initialState: TState | (() => TState)): [TState, AsyncSetState<TState>];
|
||||
Reference in New Issue
Block a user