Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Error: Vue in React throw an error when vue component disappear #91

Open
diaotai opened this issue Aug 22, 2019 · 4 comments
Open

Error: Vue in React throw an error when vue component disappear #91

diaotai opened this issue Aug 22, 2019 · 4 comments

Comments

@diaotai
Copy link

diaotai commented Aug 22, 2019

react: 16.9.0;
vue: 2.6.10;
The error will be reproduced in the following code:

import Hello from './hello.vue';

function App() {
  const [visible, setVisible] = useState(false);
  return (
    <div className="App">
      <h1 onClick={(e)=>{
        setVisible(!visible);
      }}>
         hello world
       </h1>
      {
        visible? <VueWrapper component={Hello}></VueWrapper>: null
      }
      
    </div>
  );
}

Error Message:
react-dom.development.js:10557 Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at removeChild (http://localhost:3001/static/js/0.chunk.js:84073:22)
at unmountHostComponents (http://localhost:3001/static/js/0.chunk.js:95337:13)
at commitDeletion (http://localhost:3001/static/js/0.chunk.js:95405:9)
at commitMutationEffects (http://localhost:3001/static/js/0.chunk.js:97633:15)
at HTMLUnknownElement.callCallback (http://localhost:3001/static/js/0.chunk.js:

@ricms93
Copy link

ricms93 commented Dec 11, 2019

Hi @diaotai I'm facing the same issue with Vue components. Did you manage to solve this somehow?

@ElMassimo
Copy link

I had the same problem when using react-router, and using a VueInReact-wrapped component as the child of the <Route> element.

When navigating away to a different page, it would trigger the error you mention above.

I was able to workaround it by wrapping the component with another element, for example, a <div>.

@MayRain1999
Copy link

https://github.com/timsayshey/vuera-react-vue-demo-app a demo
webpack.config.js

@chenqinyang1994
Copy link

chenqinyang1994 commented Jan 6, 2022

add a parent component to the <VueWrapper>, whose key is a timestamp
this way is worked
try it

<div key={+new Date()}>
    <VueWrapper component={Hello}></VueWrapper>
</div>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants