diff --git a/index.js b/index.js index 334b1f4..716b4c3 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,12 @@ import { useState, useMemo } from "react"; export default function useInstance(initialInstanceState) { - const [{ instance }, updateInstance] = useState({ + const [{ instance }, updateInstance] = useState(() => ({ instance: typeof initialInstanceState === "function" ? initialInstanceState() : initialInstanceState - }); + })); return useMemo(() => [ instance, function update() {