You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
The property inspector breaks when looking at an object that uses getters to access properties set on this in its constructor.
I would expect the inspector to either ignore getter-based properties of objects or to display them properly. Instead, attempting to expand an object with getters in the inspector throws TypeError: Cannot read property '0' of undefined, displaying none of the object's other properties.
If I remove the get keyword from the function definition, the inspector works as expected. However, that changes how the underlying program works, which is obviously undesirable.
To reproduce, run create-react-app and then paste the following into App.js:
importReact,{Component}from'react';importlogofrom'./logo.svg';import'./App.css';classBreaker{constructor(){// Define a property in the constructor.this.property=['The devtools will break when twirling down the "breaker" property in the state inspector.'];}getvalue(){// Use an attribute of that property in a getter.returnthis.property[0];}}classAppextendsComponent{constructor(){super();this.state={breaker: newBreaker()};}render(){return(<divclassName="App"><divclassName="App-header"><imgsrc={logo}className="App-logo"alt="logo"/><h2>Welcome to React</h2></div><p>
Accessing the getter works just fine inside the application (as well it should).
</p><p>{this.state.breaker.value}</p></div>);}}exportdefaultApp;
allypalanzi, keithk, mnpenner, klode, flyon and 5 more