Created
March 1, 2024 17:43
-
-
Save josephsavona/73526f7484499200396b54e5aabd67ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export default function CounterWithMutationTracking() { | |
const [state, setState] = useState(0); | |
let x = []; | |
let y = x; | |
y.push(state); | |
return ( | |
<div> | |
<button onClick={() => setState(state + 1)}>Increment</button> | |
<div> | |
<span>Count: {state}</span> {y[0]} | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment