October 2019
Intermediate to advanced
426 pages
11h 49m
English
In order to implement multiple Hooks, instead of having a single global variable, we should have an array of Hook values.
We are now going to refactor the value variable to a values array so that we can define multiple Hooks:
let value
Replace it with the following code snippet:
let values = []let currentHook = 0
if (typeof values[currentHook] === 'undefined') values[currentHook] = initialState
Read now
Unlock full access