Reputation: 1529
Is there a way to make useState
not to share the state between multiple instances of the same component without hacking the key
argument with Math.random()
.
const activated = useState("activated", () => false)
Upvotes: 1
Views: 361
Reputation: 4954
I'd suggest to use useState
if you want to share state. If you don't want to, you could use const activated = ref(false)
. You must not use it outside the setup
function though.
const activated = () => useState(false)
would be another option (see https://nuxt.com/docs/getting-started/state-management).
Upvotes: 0