Skip to content

Instantly share code, notes, and snippets.

@export-mike
Last active January 14, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save export-mike/f40e6e62384543cf5a1c to your computer and use it in GitHub Desktop.
Save export-mike/f40e6e62384543cf5a1c to your computer and use it in GitHub Desktop.
TopLevel Stateless Component not updating with react transform, from
import React, { Component } from 'react';
import { NICE, SUPER_NICE } from './colors';
class Counter extends Component {
constructor(props) {
super(props);
this.state = { counter: 0 };
this.interval = setInterval(() => this.tick(), 1000);
}
tick() {
this.setState({
counter: this.state.counter + this.props.increment
});
}
componentWillUnmount() {
clearInterval(this.interval);
}
render() {
return (
<h1 style={{ color: this.props.color }}>
Counter ({this.props.increment}): {this.state.counter}
</h1>
);
}
}
export const App = () => (
<div>
<h1> Change me and see that I dont reload </h1>
<Counter increment={1} color={NICE} />
<Counter increment={5} color={SUPER_NICE} />
</div>
);
@export-mike
Copy link
Author

Change the contents of h1 on line 33 and you'll find it doesn't reload...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment