Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Expected subtree parent to be a mounted class component. " after extracting component

Tags:

reactjs

I have a component (a form) which is based on office ui fabric. The form is working fine in my react application. However, since we need this at multiple places, we decided to make it an npm package.

I extracted the component and can implement it in my app. I can fill out textfields and save and it works properly. However, as soon as I open a dropdown or datepicker (basically a "Callout" from office ui fabric), I get the following error message:

"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."

and:

"react-dom.development.js:14227 The above error occurred in the component: in LayerBase in CustomizedLayer in StyledCustomizedLayer in Callout in div in NormalPeoplePicker [...] "

Since it is working when I implement it within my app directly, it must be something in the build process I think. Can anybody eloberate, what this error message means exactly?

I am using the same package versions in my component as on my app.

Can I provide any files that might help? I don't know if showing my webpack.config or package.json for my component help at all?

like image 355
nsoeth Avatar asked Nov 07 '22 21:11

nsoeth


1 Answers

Okay, it was indeed a mistake in my build process. I bundled the node_modules with my component and therefore suddenly hat two react "instances". After installing webpack-node-externals and adding

externals: [nodeExternals()]

to my webpack.config it works now.

like image 199
nsoeth Avatar answered Nov 15 '22 05:11

nsoeth