Sobes.tech
Intern — Middle

Creating a custom hook to determine the first render

livecode

Task condition

It is necessary to implement a hook useFirstRender that will return a boolean value — true if the component has just been mounted, and false in subsequent renders.

react 
const useFirstRender = () => { };

function RenderAfterFirstRender(props) {
    const isFirstRender = useFirstRender();

    if (isFirstRender) {
        return "Hwuero";
    }

    return props.children;
}

Your task is to write the body of the hook so that the RenderAfterFirstRender component correctly distinguishes the first and subsequent renders and displays the appropriate content.