mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 05:34:15 +00:00
[RN] fix TimerExample
Summary: Pressing clear would crash if timer was unmounted. Fixed by not rendering clear button when timer unmounted.
This commit is contained in:
parent
6f3849ea7b
commit
d080c8dc2b
@ -181,8 +181,12 @@ exports.examples = [
|
||||
|
||||
render: function() {
|
||||
if (this.state.showTimer) {
|
||||
var timer =
|
||||
<TimerTester ref="interval" dt={25} type="setInterval" />;
|
||||
var timer = [
|
||||
<TimerTester ref="interval" dt={25} type="setInterval" />,
|
||||
<Button onPress={() => this.refs.interval.clear() }>
|
||||
Clear interval
|
||||
</Button>
|
||||
];
|
||||
var toggleText = 'Unmount timer';
|
||||
} else {
|
||||
var timer = null;
|
||||
@ -191,9 +195,6 @@ exports.examples = [
|
||||
return (
|
||||
<View>
|
||||
{timer}
|
||||
<Button onPress={() => this.refs.interval.clear() }>
|
||||
Clear interval
|
||||
</Button>
|
||||
<Button onPress={this._toggleTimer}>
|
||||
{toggleText}
|
||||
</Button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user