The state of ref in functional components cannot be changed
Version
3.0.2
Reproduction link
https://jsfiddle.net/starfishing/6zc71eth/1/
Steps to reproduce
Declare subcomponent ButtonDemo in a new js file, Introduce child components in parent components。click child component and watch value change
What is expected?
value Increase
What is actually happening?
The component is re-rendered every time and overwrites the modified value
- browsers don't support jsx
- in html you need to use kebab-case for tag names
- move
value = Vue.ref(1)
outside the render function or don't use functional components
- browsers don't support jsx
- in html you need to use kebab-case for tag names
- move
value = Vue.ref(1)
outside the render function or don't use functional components
Does the function component support ref or other ways to maintain its own state, like react useState in function component