Skip to content

Conversation

@jackliuangel
Copy link

…, but not monitoring it at every change. So it should be an empty array.

Summary

First, THANK YOU VERY MUCH for your react-native tourial.
This is my fist PR to a public repo.
My idea is to Remove unnecessary data dependency from useEffect hook in app/index.jsx.

Problem

The useEffect that loads todos from AsyncStorage includes data in its dependency array, even though data is a static import that never changes.

I guess the original intention is NOT to monitoring the array [data]

Solution

Changed dependency array from [data] to [] to ensure the effect runs only once on component mount, which should be the intended behavior.

Testing

  • Verified app loads correctly
  • AsyncStorage data loads as expected
  • No unnecessary re-renders

…, but not monitoring it at every change. So it should be an empty array.
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

Successfully merging this pull request may close these issues.

1 participant