react-spinjs
react-spinjs copied to clipboard
update spinner when props change
I haven't tested this code, but it should work.
Here is a Test component:
class Test extends Component {
constructor(props) {
super(props);
this.state = {
red: false,
};
this.toggleColor = this.toggleColor.bind(this);
}
toggleColor() {
if (this._mount) {
this.setState({red: !this.state.red});
setTimeout(this.toggleColor, 1000);
}
}
componentDidMount() {
this._mount = true;
this.toggleColor();
}
componentWillUnmount() {
this._mount = false;
}
render() {
return (
<ReactSpinner color={this.state.red ? 'red' : 'blue'} />
);
}
}
Once again, not tested, but should work.
#6