Closed jhou12 closed 3 years ago
Nice refactor @jhou12! The syntax looks good. To address your second question, the useEffect hook achieves the same functionality found in several class-based lifecycle methods (some of which are now deprecated). I personally love this hook because that within that "empty" array as a the second argument, you can insert a variable dependency which will tell the useEffect hook to run every that dependency changes. You may want your logic inside the hook to run multiple times depending on the circumstance which would be the opportunity to take advantage of that functionality.
More info here: https://blog.logrocket.com/lifecycle-methods-with-the-useeffect-hook/
@manedurphy @pauly-van @slava000 Could anyone who knows React hooks take a look at my index.jsx refactor? 2 points of interest: 1) Is my syntax is correct and standard? 2) Is useEffect equivalent to componentDidMount?
Thank you!!!