vuera icon indicating copy to clipboard operation
vuera copied to clipboard

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

Open diaotai opened this issue 5 years ago • 4 comments

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:

diaotai avatar Aug 22 '19 12:08 diaotai

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

ricms93 avatar Dec 11 '19 17:12 ricms93

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>.

ElMassimo avatar Oct 20 '20 01:10 ElMassimo

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

MayRain1999 avatar Dec 17 '20 07:12 MayRain1999

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>

chenqinyang1994 avatar Jan 06 '22 06:01 chenqinyang1994