Skip to content

Instantly share code, notes, and snippets.

@josephsavona
Created March 1, 2024 17:43
Show Gist options
  • Save josephsavona/73526f7484499200396b54e5aabd67ea to your computer and use it in GitHub Desktop.
Save josephsavona/73526f7484499200396b54e5aabd67ea to your computer and use it in GitHub Desktop.
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