Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

old data remains rendered after update with error #4

Closed
norama opened this issue Oct 4, 2018 · 3 comments
Closed

old data remains rendered after update with error #4

norama opened this issue Oct 4, 2018 · 3 comments

Comments

@norama
Copy link

norama commented Oct 4, 2018

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.

@ghengeveld
Copy link
Member

Agreed, this should only happen when the persist flag is enabled. Can you provide a pull request?

@ghengeveld
Copy link
Member

Fixed in 3.7.1

Thanks for reporting!

@norama
Copy link
Author

norama commented Oct 4, 2018

Thanks for fixing it so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants