Instance of descendant class is shown as instance of base class in component's props
Closed this issue · 1 comments
It's looks very similar to #308, but about passing some class instance to component's props. Not related to React.Component
at all.
In short, I'm doing following:
class A { ...whatever... }
class B extends A {
constructor() {
super()
this.some = {}
}
get foo() {
return this.some.value
}
}
<MyComponent the_instance={new B()} />
Then, devtools shows me correct info:
When accessing in console $r.props.the_instance.foo
, it also works normal:
BUT when expanding the_instance
prop in devtool's sidebar, smth strange happens:
Now it's an instance of not B
but A
, and obviously crashes because can't read property of undefined.
Not fatal, but annoying thing, which complicates debugging.
Don't know how to create live demo, because have no idea how to connect react-devtools to React inside iframe.
If it can help, my .babelrc:
{
"presets": [
[ "env", {
"targets": {
"browsers": [
"last 2 versions"
]
},
"useBuiltIns": true
}],
"react"
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
[ "transform-runtime", { "polyfill": false } ],
[ "transform-builtin-extend", {
"globals": [ "Error" ]
}],
"transform-decorators-legacy",
"transform-class-properties",
"transform-async-generator-functions"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
]
}
}
}
Looks like a duplicate of #893 and #976
Repro case: https://codesandbox.io/s/887ql3mrv8