One question: is there a reason that you put 'isMobile' in the deps array of the useEffect hook? As far as I understand, if you add an empty array then useEffect will only run on mount & unmount, whereas in this case as the page is resized the boolean value of 'isMobile' will change and run useEffect again each time. It won't duplicate the event listener but seems unnecessary, unless I'm missing something?
Cheers,
Jake
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.
Hi Lori,
Nice post! I'm getting into hooks as well atm.
One question: is there a reason that you put 'isMobile' in the deps array of the useEffect hook? As far as I understand, if you add an empty array then useEffect will only run on mount & unmount, whereas in this case as the page is resized the boolean value of 'isMobile' will change and run useEffect again each time. It won't duplicate the event listener but seems unnecessary, unless I'm missing something?
Cheers,
Jake