veaury icon indicating copy to clipboard operation
veaury copied to clipboard

Veaury React 19 Strict mode bug

Open MrFlashAccount opened this issue 8 months ago • 2 comments

React 19 introduced the double-invoking ref functions in StrictMode, as mentioned in this link: https://react.dev/reference/react/StrictMode#fixing-bugs-found-by-re-running-ref-callbacks-in-development.

This feature seems to cause Veaury to unmount the applyPureVueInReact components immediately after they are mounted.

Here’s a stack trace for the unmounting event, which clearly shows that the unmount is caused by the double invocation of ref cleanups.

Image\

A potential location where the issue might be occurring is this link: https://github.com/gloriasoft/veaury/blob/60948b58c21b7e2f5900628d1b0569a24d3c97a2/src/applyVueInReact.js#L198-L199

In this section of the code, we can see that in the componentWillUnmount method, we remove a Vue portal. However, since both the componentWillUnmount method and the ref callback(https://github.com/gloriasoft/veaury/blob/60948b58c21b7e2f5900628d1b0569a24d3c97a2/src/applyVueInReact.js#L149) (as mentioned in the previous link) are invoked, Veaury unmounts the component.

MrFlashAccount avatar Apr 14 '25 10:04 MrFlashAccount

having the similar issue. Have a react app and using applyPureVueInReact to hang some legacy vue components and none of them load when using react19, but wasn't seeing any error message to indicate what was going wrong.

"react": "^19.1.0",
"vue": "^3.2.45",
"veaury": "^2.6.1",

@MrFlashAccount Thanks for tracking that down, did you have to do something to trigger those messages? wondering why ours was failing silently.

samselfridge-cnc avatar Apr 17 '25 22:04 samselfridge-cnc

@samselfridge-cnc we've added some console.error in the installed package.

We've had to disable the StrictMode for now...

MrFlashAccount avatar Apr 18 '25 07:04 MrFlashAccount