Closed
Description
I have this peace of code:
const ResultSection = ({ text }) => (
<Async watch={text} promiseFn={() => search(text)}>
<Async.Loading>Loading...</Async.Loading>
<Async.Resolved>
{(data) => (<Result data={data}/>)}
</Async.Resolved>
<Async.Rejected>{(error) => `Something went wrong: ${error.message}`}</Async.Rejected>
</Async>
);
the <Result data={data}/>
component remains rendered with the old data after rerunning promiseFn()
with new text
producing an error, resulting in
<Result data={data}/>
Something went wrong: ${error.message}
I can prevent rendering the old <Result data={data}/>
component using this code:
...
<Async.Resolved>
{(data, { error }) => {return error ? null : (
<Result data={data} />
)}}
</Async.Resolved>
...
but I think this is a workaround and the old <Result data={data}/>
component should disappear without this explicit check on error.
Metadata
Metadata
Assignees
Labels
No labels