A lib for fetching normalized data in components via react hooks.
See the full documentation for further complex use cases with several collections of data.
Basic Usage
Define your components as children of the DataContext.Provider
:
const Root = <DataContextProvider config= rootUrl: "https://momarx.com" > <Foos /> </DataContextProvider>
Where Foos will access to the data elements:
const Foos = { const data dispatch = const foos = data || {} const error setError = if error return error return <Fragment> foos || </Fragment> }
Usage with withData
Just rewrite your foos component as a container-like one:
const Foos = { const dispatch = ... }
And use the withData
hoc in order to make it more react-redux-like:
const mapDataToPropsdata ownProps return foos: data.foos || .filterfoo => footype === ownPropstype) }} const FoosContainer = Foos