Updated docs for next

This commit is contained in:
Website Deployment Script
2017-01-30 21:37:00 +00:00
parent e6d28de571
commit 3848b97327
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ const <span class="token punctuation">{</span>
&lt;Text<span class="token operator">&gt;</span>This is a placeholder<span class="token punctuation">.</span> We will come back to <span class="token keyword">this</span> and render our navigation here later<span class="token punctuation">.</span>&lt;<span class="token operator">/</span>Text<span class="token operator">&gt;</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></div><p>Alright, now we have a simple stateful component that doesn&#x27;t do much at all. We can change that. Our initial state contains one route, and the current index. That looks suspiciously just like our initial route definition in Navigator. Do you remember which actions its navigator object provided?</p><p>Push and pop, of course. That seems pretty straightforward to implement. I promised you earlier we would be using reducers to manage state at the top-level object. Sit tight.</p><h3><a class="anchor" name="step-2-reducing-the-navigation-state"></a>Step 2. Reducing the Navigation State <a class="hash-link" href="docs/navigation.html#step-2-reducing-the-navigation-state">#</a></h3><p>NavigationExperimental comes built-in with a some useful reducers, and they are all available as part of NavigationStateUtils. The two we will be using right now are called -- yep -- push and pop. They take a navigationState object, and return a new navigationState object.</p><p>We can use them to write our <code>_onNavigationChange</code> function which, given a &quot;push&quot; or &quot;pop&quot; action, will reduce the state accordingly.</p><div class="prism language-javascript"><span class="token function">_onNavigationChange<span class="token punctuation">(</span></span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token punctuation">}</span></div><p>Alright, now we have a simple stateful component that doesn&#x27;t do much at all. We can change that. Our initial state contains one route, and the current index. That looks suspiciously just like our initial route definition in Navigator. Do you remember which actions its navigator object provided?</p><p>Push and pop, of course. That seems pretty straightforward to implement. I promised you earlier we would be using reducers to manage state at the top-level object. Sit tight.</p><h3><a class="anchor" name="step-2-reducing-the-navigation-state"></a>Step 2. Reducing the Navigation State <a class="hash-link" href="docs/navigation.html#step-2-reducing-the-navigation-state">#</a></h3><p>NavigationExperimental comes built-in with some useful reducers, and they are all available as part of NavigationStateUtils. The two we will be using right now are called -- yep -- push and pop. They take a navigationState object, and return a new navigationState object.</p><p>We can use them to write our <code>_onNavigationChange</code> function which, given a &quot;push&quot; or &quot;pop&quot; action, will reduce the state accordingly.</p><div class="prism language-javascript"><span class="token function">_onNavigationChange<span class="token punctuation">(</span></span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token comment" spellcheck="true"> // Extract the navigationState from the current state:
</span> <span class="token keyword">let</span> <span class="token punctuation">{</span>navigationState<span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">;</span>
+2 -2
View File
File diff suppressed because one or more lines are too long