0.0.3 • Published 5 years ago
eslint-plugin-wanwu-jsx v0.0.3
A plugin to strict keep the style of using JSX in Vue3 project.
Rules
Each Rule
prefer-effect
When using composition API, mostly you will not need to use lifecyle methods. Or maybe you should just use effects to preform actions.
You may want to fetch data when component mounted:
onMounted(() => {
fetchData(props.id)
})This will rise a problem, how to fetch data when props.id updated. So you may face two situations:
- the
props.idnever change - you have to watch
props.idto fetch data again
So the best pratice is:
watchEffect(() => {
fetchData(props.id)
})Whenever props.id changed, fetchData invoked. If props.id never changed, then the effect will peform only once.
0.0.3
5 years ago