We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0c52a1c commit 3c38959Copy full SHA for 3c38959
src/react/helper.ts
@@ -0,0 +1,15 @@
1
+import { Children, cloneElement, isValidElement } from "react";
2
+
3
+/**
4
+ * Clone react children props
5
+ * @param children ReactNode
6
+ * @param props Parent props
7
+ */
8
+export function cloneReactChildren<P>(children: React.ReactNode, props: P): ReactNode {
9
+ return Children.map(children, child => {
10
+ if (isValidElement(child)) {
11
+ return cloneElement(child, props);
12
+ }
13
+ return child;
14
+ })
15
+}
src/react/index.ts
@@ -1,2 +1,3 @@
export * from './component';
export * from './mapState';
+export * from './helper';
0 commit comments