Timeline for Make React useEffect hook not run on initial render
Current License: CC BY-SA 4.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 14, 2023 at 12:17 | comment | added | Atal Shrivastava | Only this works for me. in my case i gave value > 0 | |
| Jun 22, 2022 at 16:33 | comment | added | A__ | If you are asking "what if selectedItem becomes null again," then yes, you need to either A) make sure it never gets set to null again, or B) initialize useState() with a value other than null, something you know it will never be set to again (i.e., -1). | |
| Jun 22, 2022 at 15:20 | comment | added | Vaggelis | And what if this particular state variable changes to this value again at some point throughout the component's lifecycle ? This is a case scenario where someone knows 100% percent that will never happen,because as a useEffect dependency,its purpose is to control the side-effects of state change. | |
| Jun 1, 2022 at 0:55 | history | answered | A__ | CC BY-SA 4.0 |