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
4.2.1
4.2.0
4.1.1
4.1.0
4.0.0
React Loads under the previous architecture, using channel
s and state components were becoming quite a pain to deal with for nested Loads
components. This release aims to simplify the usage and API and hopefully make developing with Loads
a better experience.
Breaking changes
- Removed
<IfSuccess>
,<IfError>
,<IfIdle>
,<IfLoading>
,<IfTimeout>
state components. - Removed
channel
prop from<Loads>
Features
- In favour of state components,
<Loads>
now returnsisIdle
,isTimeout
,isLoading
,isSuccess
andisError
as render props.
Migrating from v3 to v4
- Replace state components with variables returned from render props, like so:
Before:
import Loads, { IfIdle, IfLoading, IfSuccess, IfError } from 'react-loads';
<Loads fn={getRandomDog}>
{({ load, response, state, error }) => (
<div>
<p>Current state: {state}</p>
<IfIdle>
<button onClick={load}>Load random dog</button>
</IfIdle>
<IfLoading>loading...</IfLoading>
<IfSuccess>
{response && <img src={response.data.message} alt="Dog" />}
<div>
<button onClick={load}>Load another dog</button>
</div>
</IfSuccess>
<IfError>Error! {error}</IfError>
</div>
)}
</Loads>
After:
import Loads from 'react-loads';
<Loads fn={getRandomDog}>
{({ isIdle, isLoading, isSuccess, isError, load, response, state, error }) => (
<div>
<p>Current state: {state}</p>
{isIdle && <button onClick={load}>Load random dog</button>}
{isLoading && <div>loading...</div>}
{isSuccess && (
<div>
{response && <img src={response.data.message} alt="Dog" />}
<div>
<button onClick={load}>Load another dog</button>
</div>
</div>
)}
{isError && <div>Error! {error}</div>}
</div>
)}
</Loads>
3.1.0
3.0.1
3.0.0
Breaking changes
- Remove
<Action>
as an export ofreact-automata
, and create custom components for the finite set of states in React Loads (idle
,loading
,timeout
,success
anderror
- listed below in Features) - Renamed
<Loads>
propname
tochannel
as the custom state components will also make use of achannel
prop for nested<Loads>
. - Removed
<Action>
as a render prop.
Features
- In favour of
<Action>
:- Added
<IfIdle>
- Added
<IfLoading>
- Added
<IfTimeout>
- Added
<IfSuccess>
- Added
<IfError>
- Added
<IfState is={[ ... ]}>
to support multiple states
- Added
2.1.0
2.0.0
Breaking Changes
- Renamed
loadImmediately
prop toloadOnMount
. - Renamed
loadingFunc
prop tofn
. - Removed
hasLoaded
,isLoading
, andhasTimedOut
props fromonLoadingRenderer
andchildren
.
Features
- Added
state
tochildren
props. - Now internally uses React Automata to transition between loading states.
- Exports
<Action>
(an export of<Action>
from React Automata to determine what component to show based on state.