mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
update website
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
// run animation... (`runAfterInteractions` tasks are queued)
|
||||
</span><span class="token comment" spellcheck="true">// later, on animation completion:
|
||||
</span>InteractionManager<span class="token punctuation">.</span><span class="token function">clearInteractionHandle<span class="token punctuation">(</span></span>handle<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">
|
||||
// queued tasks run if all handles were cleared</span></div><h2><a class="anchor" name="timermixin"></a>TimerMixin <a class="hash-link" href="#timermixin">#</a></h2><p>We found out that the primary cause of fatals in apps created with React Native was due to timers firing after a component was unmounted. To solve this recurring issue, we introduced <code>TimerMixin</code>. If you include <code>TimerMixin</code>, then you can replace your calls to <code>setTimeout(fn, 500)</code> with <code>this.setTimeout(fn, 500)</code> (just prepend <code>this.</code>) and everything will be properly cleaned up for you when the component unmounts.</p><div class="prism language-javascript"><span class="token keyword">var</span> TimerMixin <span class="token operator">=</span> <span class="token function">require<span class="token punctuation">(</span></span><span class="token string">'react-timer-mixin'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
// queued tasks run if all handles were cleared</span></div><h2><a class="anchor" name="timermixin"></a>TimerMixin <a class="hash-link" href="#timermixin">#</a></h2><p>We found out that the primary cause of fatals in apps created with React Native was due to timers firing after a component was unmounted. To solve this recurring issue, we introduced <code>TimerMixin</code>. If you include <code>TimerMixin</code>, then you can replace your calls to <code>setTimeout(fn, 500)</code> with <code>this.setTimeout(fn, 500)</code> (just prepend <code>this.</code>) and everything will be properly cleaned up for you when the component unmounts.</p><p>This library does not ship with React Native - in order to use it on your project, you will need to install it with <code>npm i react-timer-mixin --save</code> from your project directory.</p><div class="prism language-javascript"><span class="token keyword">var</span> TimerMixin <span class="token operator">=</span> <span class="token function">require<span class="token punctuation">(</span></span><span class="token string">'react-timer-mixin'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
|
||||
<span class="token keyword">var</span> Component <span class="token operator">=</span> React<span class="token punctuation">.</span><span class="token function">createClass<span class="token punctuation">(</span></span><span class="token punctuation">{</span>
|
||||
mixins<span class="token punctuation">:</span> <span class="token punctuation">[</span>TimerMixin<span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
|
||||
Reference in New Issue
Block a user