# All files / src useIsomorphicLayoutEffect.ts

93.33% Statements 14/15
0% Branches 0/1
100% Functions 0/0
93.33% Lines 14/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    161x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

     "use client";
    import { useEffect, useLayoutEffect } from "react";

    /**
     * This is copy/pasted from react-redux which has some more information about
     * this and how to fix "invalid" warnings while running tests.
     *
     * @see {@link https://github.com/reduxjs/react-redux/blob/4c907c0870c6b9a136dd69be294c17d1dc63c8f5/src/utils/useIsomorphicLayoutEffect.js}
     */
    export const useIsomorphicLayoutEffect =
      typeof window !== "undefined" &&
      typeof window.document !== "undefined" &&
      typeof window.document.createElement !== "undefined"
        ? useLayoutEffect
        : useEffect;