mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
## Summary Fixes https://github.com/facebook/react/issues/24781 Restricting from editing props, which are class instances, because their internals should be opaque. Proposed changes: 1. Adding new data type `class_instance`: based on prototype chain of an object we will check if its plain or not. If not, then will be marked as `class_instance`. This should not affect `arrays`, ..., because we do this in the end of an `object` case in `getDataType` function. Important detail: this approach won't work for objects created with `Object.create`, because of the custom prototype. This can also be bypassed by manually deleting a prototype ¯\\\_(ツ)_/¯ I am not sure if there might be a better solution (which will cover all cases) to detect if object is a class instance. Initially I was trying to use `Object.getPrototypeOf(object) === Object.prototype`, but this won't work for cases when we are dealing with `iframe`. 2. Objects with a type `class_instance` will be marked as unserializable and read-only. ## Demo `person` is a class instance, `object` is a plain object https://user-images.githubusercontent.com/28902667/228914791-ebdc8ab0-eb5c-426d-8163-66d56b5e8790.mov |
||
|---|---|---|
| .. | ||
| src | ||
| e2e-regression.html | ||
| e2e.html | ||
| index.html | ||
| multi.html | ||
| package.json | ||
| perf-regression.html | ||
| README.md | ||
| webpack.config.js | ||
Harness for testing local changes to the react-devtools-inline and react-devtools-shared packages.
Development
This target should be run in parallel with the react-devtools-inline package. The first step then is to run that target following the instructions in the react-devtools-inline README's local development section.
The test harness can then be run as follows:
cd packages/react-devtools-shell
yarn start
Once you set both up, you can view the test harness with inlined devtools in browser at http://localhost:8080/