• Why can't react hooks be used inside condition or loop

    Why can't react hooks be used inside condition or loop?

    Mar 15, 2023

    In order to find the answer to the question in the title, let's write a simple implementation of the hook. For that, let's consider the useState hook, const React = () => { let state = []; let index = 0; const useState = (initialValue) => { const localIndex = index; index++; if…