'Two instance of React caused by injected script
In our production environment a script is injected by a third party which breaks our application with React Error 321 and indeed when I run this in the console __REACT_DEVTOOLS_GLOBAL_HOOK__.renderers I see that there are two renderers, with the same version number. I suspect that this third party script is the where the second instance of React is created but I would like to know for sure. Is there any way to find out where this second React instance is coming from?
[
{
"key": 1,
"value": {
"bundleType": 0,
"version": "16.14.0",
"rendererPackageName": "react-dom",
"overrideHookState": null,
"overrideProps": null,
"setSuspenseHandler": null,
"scheduleUpdate": null,
"currentDispatcherRef": {
"current": {}
},
"findHostInstancesForRefresh": null,
"scheduleRefresh": null,
"scheduleRoot": null,
"setRefreshHandler": null,
"getCurrentFiber": null
}
},
{
"key": 2,
"value": {
"bundleType": 0,
"version": "16.14.0",
"rendererPackageName": "react-dom",
"overrideHookState": null,
"overrideProps": null,
"setSuspenseHandler": null,
"scheduleUpdate": null,
"currentDispatcherRef": {
"current": {}
},
"findHostInstancesForRefresh": null,
"scheduleRefresh": null,
"scheduleRoot": null,
"setRefreshHandler": null,
"getCurrentFiber": null
}
}
]
Solution 1:[1]
I got a similar error (You might have more than one copy of React in the same app)
Can you move reactJs & react-dom to peerDependencies the package.json of imported package ?
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1"
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
