From e1f057419867dd860ddff5ca04938427621151c5 Mon Sep 17 00:00:00 2001 From: Issam Boubcher <99417396+Issaminu@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:01:26 +0100 Subject: [PATCH] Fix ordering in example --- src/content/learn/state-a-components-memory.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/content/learn/state-a-components-memory.md b/src/content/learn/state-a-components-memory.md index 75a1fd0b91e..92f407b1f7a 100644 --- a/src/content/learn/state-a-components-memory.md +++ b/src/content/learn/state-a-components-memory.md @@ -551,10 +551,6 @@ function useState(initialState) { return pair; } - // This is the first time we're rendering, - // so create a state pair and store it. - pair = [initialState, setState]; - function setState(nextState) { // When the user requests a state change, // put the new value into the pair. @@ -562,6 +558,10 @@ function useState(initialState) { updateDOM(); } + // This is the first time we're rendering, + // so create a state pair and store it. + pair = [initialState, setState]; + // Store the pair for future renders // and prepare for the next Hook call. componentHooks[currentHookIndex] = pair;