React
Installation
npm i awai-react
This library provides hooks for connecting Awai's state nodes with React components.
useSetState
- returns astate.set
method (can be used directly).useStateValue
- returns curent state value. It works with suspense and ensures that async node is loaded.useState
- Returns a tuple[useStateValue(state), useSetState(state)]
, just to be aligned with React'suseState
interface.useAsyncStateValue
- this hook only works withReadableAsyncState
(eg. AsyncState) and returns a result ofgetAsync
method. UnlikeuseStateValue
this hook does not suspend. That means that component is rendered even though state is not yet initialized, which results invalue
to be possiblyundefined
.