Closed imslepov closed 4 months ago
Declaring state using reactive you cannot replace replace entire object as it worked in Vue 2. This causes a bug when assigning a new state:
reactive
import { reactive } from 'vue' export default { props: {}, name: 'MyComponent', setup(props, context) { const users = reactive([]) const fetchUsers = async () => { // // Cannot assign to 'users' because it is a constant. // users = await fetch( 'https://jsonplaceholder.typicode.com/users' ).then((response) => response.json()) } return { users, fetchUsers } }, }
I suggest wrapping all types in ref, not just primitives.
ref
Declaring state using
reactive
you cannot replace replace entire object as it worked in Vue 2. This causes a bug when assigning a new state:I suggest wrapping all types in
ref
, not just primitives.