const container = document.getElementById('root'); const root = ReactDOM.createRoot(container); root.render(<p>Hello</p>);
onClick={shoot}
instead of onClick="shoot()"
.<button onClick={() => shoot("Goal!")}>Take the shot!</button> <button onClick={(event) => shoot("Goal!", event)}>Take the shot!</button>
{ cars.length > 0 && <h2> You have {cars.length} cars in your garage. </h2> }
useEffect(() => { //Runs on the first render //And any time any dependency value changes }, [prop, state]);
const [ state, dispatch ] = useReducer( reducer, initialValue );
Labels: React.js