Last active
January 14, 2016 16:31
-
-
Save export-mike/f40e6e62384543cf5a1c to your computer and use it in GitHub Desktop.
TopLevel Stateless Component not updating with react transform, from
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change the contents of h1 on line 33 and you'll find it doesn't reload...