Commit Graph

3 Commits

Author SHA1 Message Date
rektdeckard
2a030b08cd refactor(app): switch to @phosphor-icons/core and format files 2023-01-08 02:10:49 -07:00
rektdeckard
d5609d3c57 useTransientState: set default delay (1000ms) and resolve retriggers
When setTransientState() triggers a new timeout, we clear any pending
timeouts to prevent stale state from being applied if a superceding
value was set in the interim.

Maybe in future we should also allow users to cancel pending transitions
directly, by returning useTimeoutFn's cancel() function along with the
state and setter.
2020-08-09 20:54:18 -04:00
Tobias Fried
6202c4d2bb useTransientState: implement hook
This utility hook provides access to a piece of state and a setter
function, which can be used to supply a temporary value and a duration
for which it is valid, before reverting to preceeding value. Following
the pattern:

const [value, setTransientValue] = useTransientValue<number>(42, 5000);
setTransientValue(69); // value === 69 for 5000ms, before returning to 42

We can easily fire and forget a temporary state transition.
2020-07-31 19:53:12 -04:00