Is there a way to reset a component?
See original GitHub issueCurrently if there’s a component I want to reinitialize, I have to include the component as an expression, set that expression to blank, then reset the expression back to the component
<div v-component="{{currentComponent}}"></div>
container.currentComponent = '';
Vue.nextTick(function () {
container.currentComponent = 'origional-component';
});
Is there a better way to do this?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Is there a proper way of resetting a component's initial data in ...
There are three ways to reset component state: Define key attribute and change that; Define v-if attribute and switch it to false to...
Read more >Best Practices For Resetting an ES6 React Component's State ...
Updating any field in the form updates the `state` of the form, clicking 'Cancel' should reset the form to the initial state, and...
Read more >Preserving and Resetting State - React Docs
State is isolated between components. React keeps track of which state belongs to which component based on their place in the UI tree....
Read more >How do I reset a component in Figma? - website builder
1. Select the component you want to reset. · 2. Click the “gear” icon in the top right corner and select “Reset Component.”...
Read more >Using key prop to reset React components - Amit Merchant
To fix this, we can introduce the useEffect hook in the <FormComponent> component and update the internal state like so. useEffect(() => { ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Caution,
Object.assign(this.$data, this.$options.data())
does not bind the context intodata()
. So if you are usingthis
into yourdata
method you may want to apply the context withYou can do this:
Object.assign(this.$data, this.$options.data())