mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 06:15:15 +00:00
never setState after component is unmounted
This commit is contained in:
@@ -23,12 +23,18 @@ class GExample extends Component{
|
|||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!this._unmounted) {
|
||||||
this.setState({
|
this.setState({
|
||||||
fill: '#856'
|
fill: '#856'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentWillUnmount = () => {
|
||||||
|
this._unmounted = true;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Svg
|
return <Svg
|
||||||
height="100"
|
height="100"
|
||||||
|
|||||||
Reference in New Issue
Block a user