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

The state - loadCounter is out of sync #31

Open
xipeter opened this issue Jul 19, 2023 · 1 comment
Open

The state - loadCounter is out of sync #31

xipeter opened this issue Jul 19, 2023 · 1 comment

Comments

@xipeter
Copy link

xipeter commented Jul 19, 2023

this.setState({ loadCounter: this.state.loadCounter + 1 }, () => {

So, when there're multiple images, the state - loadCounter won't keep consistent between different images, say I have four images, in some cases, say we have 4 images, the state loadCounter would be 2 rather than 4, because when the 3rd, and 4th image got loaded, the state is 1 at the moment of reading the value, any thoughts?

@andrew1007
Copy link
Owner

Yes, there can be an asynchronicity issue. If the component is converted to use hooks, then there can be a guarantee that the counter will stay in sync

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