Joel.Watson92@gmail.com | LinkedIn: /in/joel3rbear | Twitter: @Joel3rBear
The component lifecycle is refering to the the different points in the process of rendering and unrendering the component like componentDidMount or componentDidUpdate
Functional components are preferred over class components
The issue with the code below is that it is using the useEffect hook inside of a for-loop.
`import React, {useState, useEffect} from ‘react’;
function MyComponent(props) { const [count, setCount] = useState(0);
function changeCount(e) { setCount(e.target.value); }
let renderedItems = []
for (let i = 0; i < count; i++) { useEffect( () => { console.log(‘component mount/update’); }, [count]);
renderedItems.push(<div key={i}>Item</div>); }
return (<div> <input type=’number’ value={count} onChange={changeCount}/> {renderedItems} </div>); }`