You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useEffects without a second argument with an array of dependencies can run in an infinite loop - since they run whenever the component re-renders, and if you're setting state within the useEffect, then the component re-renders, which re-runs the useEffect, sets state again, re-renders the component, re-runs the useEffect... on and on
to avoid this - I tend to follow these rules
if I want it to run only once (the first time the component renders) - use an empty dependency array
useEffect(()=>{doStuff()},[]})
If I do something based on a state value, add it to the dependency array so the effect only runs when the state changes between re-renders
The text was updated successfully, but these errors were encountered:
week7-away-days/src/components/reviews/DisplayReviews.js
Lines 9 to 18 in 1bdfc16
week7-away-days/src/components/accommodation/DisplayAccommodation.js
Lines 8 to 17 in 1bdfc16
useEffects without a second argument with an array of dependencies can run in an infinite loop - since they run whenever the component re-renders, and if you're setting state within the useEffect, then the component re-renders, which re-runs the useEffect, sets state again, re-renders the component, re-runs the useEffect... on and on
to avoid this - I tend to follow these rules
The text was updated successfully, but these errors were encountered: