select2-component icon indicating copy to clipboard operation
select2-component copied to clipboard

React gives Unable to find node on an unmounted component

Open octylFractal opened this issue 2 years ago • 5 comments

Version(if relevant): 5.10.4

Environment(if relevant): React 17.0.2

Code(if relevant):

// given:
selected: string | undefined;
data: Select2Data;
setSelected: (selected: string) => void;

// then:
<Select2
        data={data}
        value={selected}
        update={(v): void => setSelected(v as string)}
    />

Expected:

Functioning component

Actual:

Error: Unable to find node on an unmounted component.
    at findHostInstanceWithWarning (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24281:19)
    at Object.findDOMNode (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24804:12)
    at Select2.componentDidMount (webpack-internal:///./node_modules/.pnpm/[email protected]/node_modules/select2-react-component/dist/select2.js:124:65)
    at commitLifeCycles (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20658:24)
    at commitLayoutEffects (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:23421:7)
    at HTMLUnknownElement.callCallback (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:3945:14)
    at Object.invokeGuardedCallbackDev (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:3994:16)
    at invokeGuardedCallback (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
    at commitRootImpl (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:23146:9)
    at unstable_runWithPriority (webpack-internal:///./node_modules/.pnpm/[email protected]/node_modules/scheduler/cjs/scheduler.development.js:468:12)

I notice that there has been a multitude of releases, all the way up to 6.1.0, but they're not on NPM. Is there somewhere else this package is released to?

octylFractal avatar Sep 13 '21 19:09 octylFractal

Also, I think this is technically a duplicate of #22, differing react versions. It looks like the current master branch uses React 17, but as I mentioned, it's not released as far as I can tell.

octylFractal avatar Sep 13 '21 19:09 octylFractal

It's a moporepo, the missing versions eg: 6.0.0 only changes select2-vue-component's code, so the uneffected select2-react-component doesn't have 6.0.0. I will release the master several hours later.

plantain-00 avatar Sep 14 '21 09:09 plantain-00

v6.1.1 released now.

plantain-00 avatar Sep 14 '21 10:09 plantain-00

I'm getting this message with React 18, any advice?

galanblancom avatar Jun 10 '22 11:06 galanblancom

same here, I also get this error with react 18 and select2-react v6.1.1

maxcmoi89 avatar Jul 13 '23 08:07 maxcmoi89