Controlling component reuse from within the component #9656
Unanswered
PathriK
asked this question in
Help/Questions
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TLDR;
In the linked POC code, the desired behavior is that the text below checkbox needs to be in sync with the check box label. I am looking for a change outside of App and BlackboxComponent, probably within WrapperComponent, that would make this work without adding key in the App's template for the WrapperComponent.
POC:
https://codesandbox.io/s/vue-2-playground-forked-8rujnd?file=/src/main.js
More details:
I am working on a project where the pages are implemented using a jQuery based in-house framework. We are in the process of migration that to Vue.js. There is a external component (Vue.js component) that unfortunately we don't have control over. I am facing a challenge in integrating that with our rest of the page. Have created a sample in the above codesandbox link
Here, BlackboxComponent is the third party component that we don't control. WrapperComponent is the component that we developed to interface our page/component with the BlackboxComponent. BlackboxComponent expects config in a JSON format and also it is not reactive. In the sense, if the config changes, BlackboxComponent does not re-render. We are fine with that. The issue is that when a single component contains two references of WrapperComponent (in turn BlackboxComponent) rendered conditionaly, Vue tries to reuse the existing component and hence the changes don't reflect. The solution that I can think of is providing key wherever we use the WrapperComponent. But that seems like a incovenience for whoever is including the WrapperComponent in their template. Is there any way for WrapperComponent to control this? That is have some logic in WrapperComponent that tells Vue if a new component should be created or an existing component should be reused. In other words, is it possible to provide the key for WrapperComponent from inside the WrapperComponent component itself?
POC code, incase access to above link is restricted or removed:
Beta Was this translation helpful? Give feedback.
All reactions