This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
Releases: jxom/react-loads
Releases · jxom/react-loads
9.0.1
9.0.0
BREAKING CHANGES
-
There is a new
useLoads
API wherecontext
is now mandatory.v8 and below
useLoads(fn, config)
v9
useLoads(context, fn, config)
- With this change, this means that every response gets automatically stored in the cache.
- There may be instances where you don't want to use the automatic caching, you can disable it by setting
loadPolicy: 'load-only'
in theuseLoads
config. - Read more on it's usage
-
Removed the
id
&args
attributes from theuseLoads
config options in favor of avariables
optionv8 and below
useLoads(fn, { id: [fooId, barId], args: [fooId, barId, { baz: 'hello' }] })
v9
useLoads(context, fn, { variables: [fooId, barId, { baz: 'hello' }] })
-
Removed
isTimeout
in favour ofisPendingSlow
-
Removed
enableBackgroundStates
in favour ofisReloading
-
Renamed the
load
prop tofn
in<Loads>
v8 and below
<Loads load={fetchDogs}>
v9
<Loads fn={fetchDogs}
-
Renamed the
_namespace
&load
attributes increateResource
tocontext
&fn
v8 and below
createResource({ _namespace: 'foo', load: fetchFoo })
v9
createResource({ context: 'foo', fn: fetchFoo })
-
Configuration is now placed in a
config
prop on<Provider>
v8 and below
<Loads.Provider timeout={500}> {/* ... */} </Loads.Provider>
v9
const config = { timeout: 500 }; function App() { return ( <Loads.Provider timeout={500}> {/* ... */} </Loads.Provider> ); }
-
Removed
useLoadsCache
in favour ofuseCache
-
Removed state components (
<Loads.Pending>
,<Loads.Resolved>
, etc)- Use state variables (
isPending
,isResolved
, etc) instead
- Use state variables (
Features
- Introduced a new
useDeferredLoads
hook.- This replicates the old
useLoads(fn, { defer: true })
, butuseDeferredLoads
doesn't require acontext
. - Read more on it's usage
- This replicates the old
- Added a new
isReloading
state- This is truthy when the async function is reloading (typically when
fn
is manually invoked, or data exists in the cache)
- This is truthy when the async function is reloading (typically when
- Add polling support
- Add deduping support
- Added new config options:
variables
cacheStrategy
cacheTime
dedupingInterval
onReject
onResolve
pollingInterval
pollWhenHidden
rejectRetryInterval
revalidateTime
revalidateOnWindowFocus
- Introduced a new
useGetStates
hook to compose promise states. Read more - Introduced a new
preload
function for preloading data. Read more