import React from "react"; import {renderToStaticMarkup} from "react-dom/server"; import {useIsMounted} from "../src"; function Example() { const [, isMounted] = useIsMounted({rerender: true}); return

{isMounted ? "mounted" : "not mounted"}

; } describe("useIsMounted", () => { it("should export a function", () => { expect(useIsMounted).toBeInstanceOf(Function); }); it("should return false before mount (default)", () => { const text = renderToStaticMarkup(); expect(text).toBe("

not mounted

"); }); it("should return false before mount (beforePaint)", () => { const text = renderToStaticMarkup(); expect(text).toBe("

not mounted

"); }); });