Thanks for the feedback 😊
I agree, this is another possible solution and it should work great.
The only thing to look for here, is that your effect doesn't have different logic with none relevant dependencies (which it shouldn't have!), though i did see some mixed logic inside effects in some code sources.
I think i will add this as another solution in the post. Thank you 🙏
Edit
Forgot to mention, regarding the magic of ref.current in effects. Its actually just a mutable box handled by react, not different than state or reducers really. It will change every time the effect runs, its just attached to the "instance" of the component so you can access it outside the effect's scope.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the feedback 😊
I agree, this is another possible solution and it should work great.
The only thing to look for here, is that your effect doesn't have different logic with none relevant dependencies (which it shouldn't have!), though i did see some mixed logic inside effects in some code sources.
I think i will add this as another solution in the post. Thank you 🙏
Edit
Forgot to mention, regarding the magic of
ref.current
in effects. Its actually just a mutable box handled by react, not different thanstate
orreducers
really. It will change every time the effect runs, its just attached to the "instance" of the component so you can access it outside the effect's scope.