React hooks to interact with an API from a stateless component using axios.
npm i react-api-hooks -suseParamsOutputReact hook to keep query parameters in state.
Used in conjunction with the other hooks to filter and pagination API calls.
Includes the ability the debounce an update, which is useful for delaying API calls while the user is typing.
Kind: global function
Returns: useParamsOutput - output
| Param | Type | Default | Description |
|---|---|---|---|
| initialParams | Object | The initial parameters to keep in states | |
| debounceWait | number | 500 | The time to debounce the params update when calling debouncedUpdateParams |
ObjectThe object returned by the useParams hook.
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| params | Object | The current params to be used when making an API call. |
| isStale | boolean | Is their a debounced params update waiting to timeout. (Are we waiting for the user to stop typing) |
| setParams | setParamsFunc | Function used to set new parameters |
| updateParams | updateParamsFunc | Function used to update current parameters |
| debouncedSetParams | setParamsFunc | Debounced call made to setParams |
| debouncedUpdateParams | updateParamsFunc | Debounced call made to updateParams |
functionsetParams property of useParamsOutput
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| newParams | Object | New params object that overwrites the current params. |
functionupdateParams property of useParamsOutput
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| paramsUpdate | Object | Partial update to be merged with current params. |