mirror of
https://github.com/status-im/react-native.git
synced 2025-02-09 16:14:47 +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() {
|
render: function() {
|
||||||
if (this.state.showTimer) {
|
if (this.state.showTimer) {
|
||||||
var timer =
|
var timer = [
|
||||||
<TimerTester ref="interval" dt={25} type="setInterval" />;
|
<TimerTester ref="interval" dt={25} type="setInterval" />,
|
||||||
|
<Button onPress={() => this.refs.interval.clear() }>
|
||||||
|
Clear interval
|
||||||
|
</Button>
|
||||||
|
];
|
||||||
var toggleText = 'Unmount timer';
|
var toggleText = 'Unmount timer';
|
||||||
} else {
|
} else {
|
||||||
var timer = null;
|
var timer = null;
|
||||||
@ -191,9 +195,6 @@ exports.examples = [
|
|||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{timer}
|
{timer}
|
||||||
<Button onPress={() => this.refs.interval.clear() }>
|
|
||||||
Clear interval
|
|
||||||
</Button>
|
|
||||||
<Button onPress={this._toggleTimer}>
|
<Button onPress={this._toggleTimer}>
|
||||||
{toggleText}
|
{toggleText}
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user