Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99392898
useStateAsync.d.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jan 24, 03:49
Size
767 B
Mime Type
text/x-java
Expires
Sun, Jan 26, 03:49 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23788945
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
useStateAsync.d.ts
View Options
import React from 'react';
export declare 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>];
Event Timeline
Log In to Comment