Skip to content

Prevent "maximum update depth exceeded" error when pass image as a new object on each render #269

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

Merged

Conversation

retyui
Copy link
Contributor

@retyui retyui commented Oct 18, 2021

Summary

Don't use source as useEffect dependency when it objects, to fix next issue:

useImageDimensions({uri: '...'})
                   ^^^
                   ERROR: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect,
                                   but useEffect either doesn't have a dependency array, 
                                   or one of the dependencies changes on every render.

Test Plan

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

See expo snack below...

Compatibility

OS Implemented
iOS
Android
Web

Checklist

…w object on new render

```
useImageDimensions({uri: '...'})
                                  ^^^
                                  ERROR: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
```
@retyui retyui changed the title Prevent "maximum update depth exceeded" error when pass image as a new object on new render Prevent "maximum update depth exceeded" error when pass image as a new object on each render Oct 18, 2021
Copy link
Member

@LinusU LinusU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LinusU LinusU added patch Increment the patch version when merged release Create a release when this pr is merged labels Oct 19, 2021
@LinusU LinusU merged commit 2e8c445 into react-native-community:master Oct 19, 2021
@retyui retyui deleted the fix-infinite-use-effect branch October 19, 2021 13:42
@pvinis
Copy link
Member

pvinis commented Oct 19, 2021

🚀 PR was released in v2.8.0 🚀

@pvinis pvinis added the released This issue/pull request has been released. label Oct 19, 2021
@github-actions github-actions bot mentioned this pull request Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants