This is a problem after react was packaged with webpack.

  node.js, question

I wrote a section of code with React, most of which App.jsx is directly photographed.React-UI-TreeThis component’s browser responded to such an error after compiling and packaging with webpack. the code should be no problem. I don’t know where the problem is 0.0

图片描述
图片描述

Figure 1 Left Code:

import ReactDOM from 'react-dom';
 import cx from 'classnames';
 import React from 'react';
 import Tree from 'react-ui-tree';
 
 
 export default class App extends React.Component {
 
 constructor() {
 super();
 this.state = {
 active : null,
 tree : {
 "module": "react-ui-tree",
 "children": [{
 "collapsed": true,
 "module": "dist",
 "children": [{
 "module": "node.js"
 }]
 }]
 bracket
 };
 bracket
 
 renderNode(node) {
 return (
 <span className={cx('node', {
 'is-active': node === this.state.active
 })} onClick={this.onClickNode.bind(null, node)}>
 {node.module}
 </span>
 );
 bracket
 
 onClickNode(node) {
 this.setState({
 active: node
 });
 bracket
 
 render() {
 return (
 <div className="app">
 <div className="tree">
 <Tree
 paddingLeft={20}
 tree={this.state.tree}
 onChange={this.handleChange}
 isNodeCollapsed={this.isNodeCollapsed}
 renderNode={this.renderNode}
 />
 </div>
 <div className="inspector">
 <button onClick={this.updateTree}>update tree</button>
 <pre>
 {JSON.stringify(this.state.tree, null, '  ')}
 </pre>
 </div>
 </div>
 );
 bracket
 
 handleChange(tree) {
 this.setState({
 tree: tree
 });
 bracket
 
 updateTree() {
 var tree = this.state.tree;
 tree.children.push({module: 'test'});
 this.setState({
 tree: tree
 });
 bracket
 
 bracket

Take youthis.state.activeThe source code posted, compiled really don’t want to see, see also can’t give you a problem

renderChange:

render() {
 return (
 <div className="app">
 <div className="tree">
 <Tree
 paddingLeft={20}
 tree={this.state.tree}
 onChange={this.handleChange}
 isNodeCollapsed={this.isNodeCollapsed}
 renderNode={this.renderNode.bind(this)}
 />
 </div>
 <div className="inspector">
 <button onClick={this.updateTree}>update tree</button>
 <pre>
 {JSON.stringify(this.state.tree, null, '  ')}
 </pre>
 </div>
 </div>
 );
 bracket