Are dynamic components being destroyed when the key changes?

Viewed 24

Maybe I'm bad at looking but I can't the proper answer. I'm using something like that:

<component
  :is="activeModal"
  :key="key"
  :passedItem="passedItem"
  :isEdited="isEdited"
  v-model="showCreator"
></component>

This component is for creating and editing 6 different components (they are basically the same, just some different input fields). I had a problem when I used this component to create new thing. In my method, let's say addStudent, I was creating key like that:

this.key = 'CreateStudent'

But when I opened it for a second time, the old data was showing. So I created local data studentIndex = 0, and I'm incrementing it every time I add new Student:

this.key = 'CreateStudent' + this.studentIndex;
this.studentIndex++;

Is this a correct approach and old dynamic components will be removed, so it doesn't overwhelm my app?

Should I set studentIndex to 0 when it hit like 10k?

0 Answers
Related