Recoilize icon indicating copy to clipboard operation
Recoilize copied to clipboard

TypeError: Cannot read properties of undefined (reading '_internalRoot')

Open cuitianze opened this issue 3 years ago • 7 comments

React With single-spa

Uncaught TypeError: Cannot read properties of undefined (reading '_internalRoot')

with the function:

const createDevToolDataObject = (filteredSnapshot, diff) => {
    if (diff === undefined) {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
      };
    } else {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
        indexDiff: diff,
      };
    }
  };

same issue with

Originally posted by @adamdaly in https://github.com/open-source-labs/Recoilize/issues/136#issuecomment-1091899426

cuitianze avatar May 21 '22 13:05 cuitianze

Same problem with nextjs 12.1.6 Used https://github.com/open-source-labs/Recoilize#in-order-to-integrate-nextjs-applications-with-recoilizedebugger-follow-the-example-below

tsepen avatar May 27 '22 08:05 tsepen

Can reproduce it. "recoilize": "^3.1.6" "next": "12.1.6",

ZeroPie avatar Jun 02 '22 21:06 ZeroPie

Same for me. React 18, custom webpack build. Cannot read properties of undefined (reading '_internalRoot')

hodler-buidler avatar Jun 09 '22 12:06 hodler-buidler

Has anyone found a workaround or solution for this?

React 18.1.0 NextJS 12.1.6

jimjiminyjimjim avatar Jun 26 '22 11:06 jimjiminyjimjim

#172 Not sure if it's the best way But it can work in a single React.createRoot environment

boenfu avatar Jun 27 '22 12:06 boenfu

This issue happens when render is used as a standalone function instead of a method, do:

const root = createRoot(container)

root.render(<App />)

instead of:

const { render } = createRoot(container)

render(<App />)

arthwood avatar May 16 '23 09:05 arthwood

@arthwood you, sir, are the real hero. Thanks, it worked for me!

igorrfc avatar Jun 15 '23 15:06 igorrfc