Skip to content

"isLoading" slightly misleading #2

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

Closed
philip-peterson opened this issue Sep 20, 2018 · 3 comments
Closed

"isLoading" slightly misleading #2

philip-peterson opened this issue Sep 20, 2018 · 3 comments

Comments

@philip-peterson
Copy link
Contributor

philip-peterson commented Sep 20, 2018

When I saw the existence of isLoading, I assumed it would be true from the moment the react-async component mounted until the query promise I provided was completed. Instead, though, isLoading is momentarily false for the first render or so, until the state has had a chance to update, because the component doesn't know that a promiseFn was necessarily provided.

Two options I see:

  • on construction, set isLoading to true if there is a promiseFn provided and it produces a promise
  • naming clarity: provide a new param, isReady that is set to !!finishedAt
  • provision of some kind of warning in the documentation about isLoading not being true initially.

The first option is probably the most intuitive for the user.

@ghengeveld
Copy link
Member

ghengeveld commented Sep 20, 2018

Thanks for the feedback, I love to hear about these unexpected/unclear behaviors. As I was developing it, I did initially have isLoading set to true on mount. I changed that when I added the deferFn, because in that scenario, isLoading=true doesn't apply on mount. I like your first suggestion best. I think it does make sense in most use cases and it's what people would expect.

isReady is reserved for future use.

@ghengeveld
Copy link
Member

I would love to merge a pull request if you can provide one.

@ghengeveld
Copy link
Member

Fixed in v3.6.2.

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