Skip to content

Latest commit

 

History

History
67 lines (57 loc) · 942 Bytes

File metadata and controls

67 lines (57 loc) · 942 Bytes

Code Snippets

Perf.printWasted()
// Can't use mixin, use fat arrow
render() {
  return (
    <input type="text"
      value={this.state.inputText}
      onChange={e => this.setState({inputText: e.target.value})}
      onKeyPress={this.handleKeyPress} />
  );
}
// Weird ES6
moveBox(id, left, top) {
  this.setState(update(this.state, {
    boxes: {
      [id]: {
        $merge: {
          left: left,
          top: top
        }
      }
    }
  }));
}
// Iterating
return (
  <div>
    {this.props.list.map(function(data, idx) {
      return <Component data={data} key={idx} />;
    })}
  </div>
);
<RouteHandler {...this.props} />

Clearing Timer

componentDidMount() {
  this.interval = setInterval(this.tick, 1000);
}

componentWillUnmount() {
  clearInterval(this.interval);
}

Addons

import React from 'react/addons';
const TestUtils = React.addons.TestUtils;