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
importReactfrom'react';importReactDOMfrom'react-dom';// import PropTypes from 'props-type';constHello=({ name })=><h1>Hello {name}!</h1>;classShowMyErrorextendsReact.Component{constructor(props){super(props);this.state={error: false};}componentDidCatch(error,info){this.setState({ error, info });}render(){if(this.state.error){return(<div><h1>
Error AGAIN: {this.state.error.toString()}</h1>{this.state.info&&this.state.info.componentStack.split("\n").map(i=>{return(<divkey={i}>{i}</div>);})}</div>);}returnthis.props.children;}}classBrokenextendsReact.Component{constructor(props){super(props);this.state={throw: false,count: 0};}render(){if(this.state.throw){thrownewError("YOLO");}return(<div><buttononClick={e=>{this.setState({throw: true});}}>
button will render error.
</button><buttononClick={e=>{this.setState(({ count })=>({count: count+1}));}}>button will not throw</button><div>{"All good here. Count: "}{this.state.count}</div></div>);}}classAppextendsReact.Component{render(){conststyles={fontFamily: "sans-serif",textAlign: "center"};return(<divstyle={styles}><Helloname="ShowMyError"/><h2>
Start clicking to see some {"\u2728"}magic{"\u2728"}</h2><ShowMyError><Broken/></ShowMyError></div>);}}ReactDOM.render(<App/>,document.getElementById("root"));
以上的例子在Anu中的截图是:
下面是在react 16.2.0中的截图
The text was updated successfully, but these errors were encountered:
使用的是anu最新版本,从github直接下的.
以上的例子在Anu中的截图是:
![2017-12-14 11 07 34](https://user-images.githubusercontent.com/16814336/33986824-a3a220ec-e123-11e7-80e2-dc34301970f3.png)
![2017-12-14 11 07 40](https://user-images.githubusercontent.com/16814336/33986831-a8dc11e4-e123-11e7-98cf-f5c646d2e51c.png)
下面是在react
16.2.0
中的截图The text was updated successfully, but these errors were encountered: