diff --git a/.changeset/lovely-birds-clap.md b/.changeset/lovely-birds-clap.md new file mode 100644 index 0000000..88d81d1 --- /dev/null +++ b/.changeset/lovely-birds-clap.md @@ -0,0 +1,8 @@ +--- +"@zayne-labs/toolkit": patch +--- + +refactor: update createZustandContext to use createElement instead of cloneElement + +- Replaced the use of `cloneElement` with `createElement` in the `createZustandContext` function +- This change simplifies the code and aligns with the recommended React API usage diff --git a/src/react/zustand/createZustandContext.ts b/src/react/zustand/createZustandContext.ts index 57452ac..51ab78c 100644 --- a/src/react/zustand/createZustandContext.ts +++ b/src/react/zustand/createZustandContext.ts @@ -1,5 +1,5 @@ import type { SelectorFn } from "@/type-helpers"; -import { cloneElement } from "react"; +import { createElement } from "react"; import type { StoreApi, UseBoundStore } from "zustand"; import { type CustomContextOptions, createCustomContext, useConstant } from "../hooks"; @@ -28,7 +28,7 @@ const createZustandContext = < "createStore" in restOfProps ? restOfProps.createStore() : restOfProps.value ); - return cloneElement(Provider as never, { value: useZustandStore }, children) as React.ReactNode; + return createElement(Provider, { value: useZustandStore }, children); } const useBoundStore = (selector: SelectorFn) => useCustomContext()(selector);