Skip to content

Instantly share code, notes, and snippets.

@Sergioamjr
Created May 22, 2021 15:50
Show Gist options
  • Select an option

  • Save Sergioamjr/2d6007cd2c2ddb66c2620f6f9c2ba1e3 to your computer and use it in GitHub Desktop.

Select an option

Save Sergioamjr/2d6007cd2c2ddb66c2620f6f9c2ba1e3 to your computer and use it in GitHub Desktop.

Revisions

  1. Sergioamjr created this gist May 22, 2021.
    14 changes: 14 additions & 0 deletions useLayoutEffect.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import { useState, useLayoutEffect } from "react";

    function Component() {
    const [isDOMLoaded, setIsDOMLoaded] = useState(false);

    useLayoutEffect(() => {
    setIsDOMLoaded(true);
    window.localstorage.getItem("...");
    }, []);

    return(
    //...
    )
    }