Subscribe on changes!

[FR] Preserve states like React's state variables

avatar
Jun 13th 2021

What problem does this feature solve?

Currently, when editing code in <script>, the states will be discarded, it's particularly obvious when using render functions instead of templates, since modifying a style in render function will lose states of the edited component, it'd be great if Vue could remember the states like React's state variables. This way, the developer experience for writing render functions will be hugely improved.

What does the proposed API look like?

Preserve states like React's state variables.

avatar
Jun 19th 2021

This is technically not possible (while preserving correctness) because Vue state is actual state created inside a closure whereas React hooks state is stored on the underlying component instance.