I'm creating a new Vue 3 project and I see a lot of people stating references like this online.
const myVariable = ref(false)
Why are we suddenly using const in Vue 3?
I know that refs wrap them somehow to make them editable, but I still don't understand why they are not declared like this:
let myVariable = ref(false)
I know this may sound silly to a Vue 3 developer, but I can't understand the reason behind changing the value to a constant.
Meanwhile, I'm using const declarations in the composition API, but I'd like to understand the reasoning behind it
This is preference, but the argument for using
const
is when the value has not changed, for example:With
ref()
you are not replacing variables, you are replacing propertiesThe following is the explanation of
eslint
:Documentation (at the time of writing): https://eslint.org/docs/latest/rules/prefer-const