react icon indicating copy to clipboard operation
react copied to clipboard

[DevTools Bug]: Selecting/deselecting boolean from DevTools Component props causing loss of class functions

Open a-gehlot opened this issue 2 years ago • 4 comments

Website or app

https://github.com/a-gehlot/react-error

Repro steps

  1. Install webpack, react, babel with "npm install" in terminal.

  2. Bundle app with webpack via "webpack --watch --mode=developement" in terminal.

  3. Open up "index.html" in Chrome and open React DevTools. Under Components, there should be a Dog component within a Person component, where the Person is passed as a prop to the Dog.

  4. Under Dog props, there should be a person object with a value of present being true. If you click the button, the value of present should change to false, the number should switch to 0, and the checkbox should get deselected. However, if you manually select the checkbox to change between true/false, the prop seems to lose its prototype references to the original JS class, as an error stating it cannot find the function will be shown.

https://user-images.githubusercontent.com/52260394/175361370-b6ff5dea-788f-4564-a279-57e3cae11a4d.mov

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

a-gehlot avatar Jun 23 '22 17:06 a-gehlot

Hi This is because React needs to copy your state before modifying it. When copying a non-primitive state, React assumes it is an object or an array. See: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberReconciler.new.js#L609 In this process, the class instance becomes an object and checkPresence is gone. We'll need to update react for fix this issue.

mondaychen avatar Jun 28 '22 03:06 mondaychen

After discussion with team, we decided to make a change in devtools to stop allowing editing inside classes. Class internals should be opaque.

mondaychen avatar Jun 29 '22 15:06 mondaychen

@mondaychen is anyone working on its resolution?

official-akshayjadhav avatar Oct 08 '22 07:10 official-akshayjadhav

Hi @official-akshayjadhav. Not yet.

mondaychen avatar Oct 11 '22 22:10 mondaychen