Function
Static Public Summary | ||
public |
Creates a new event that allows subscribers to add and remove event handlers. |
|
public |
globalReducer(initialValue: Object, reducer: Object, onStateChange: function(state: Object)): function(selector: function = undefined, onComponentStateChanged: function = undefined): [Object, Object] Creates a global reducer for use within any number of components. |
|
public |
usePromise(promise: Promise): [Object, Error, boolean] Use a promise and receive [data, error, loading] values. |
Static Public
public createEvent(): function source
import {createEvent} from 'react-hook-utils/dist/index.es.js'
Creates a new event that allows subscribers to add and remove event handlers.
public globalReducer(initialValue: Object, reducer: Object, onStateChange: function(state: Object)): function(selector: function = undefined, onComponentStateChanged: function = undefined): [Object, Object] source
import {globalReducer} from 'react-hook-utils/dist/index.es.js'
Creates a global reducer for use within any number of components. The function returned allows for a selector function to be passed to limit the re-renders of the consuming component.
Params:
Name | Type | Attribute | Description |
initialValue | Object | The initial value for the state. |
|
reducer | Object | The dispatch functions. |
|
onStateChange | function(state: Object) |
|
onStateChange An optional callback for when the state changes. Can be used for persisting to local storage. |
Return:
function(selector: function = undefined, onComponentStateChanged: function = undefined): [Object, Object] |
public usePromise(promise: Promise): [Object, Error, boolean] source
import {usePromise} from 'react-hook-utils/dist/index.es.js'
Use a promise and receive [data, error, loading] values. It is strongly recommended to use in conjunction with useMemo.
Params:
Name | Type | Attribute | Description |
promise | Promise | The promise to use. |
Return:
[Object, Error, boolean] |