Skip to content

Commit 50f72ca

Browse files
committed
feat: Add BigInt support for React 19
1 parent a40b8e3 commit 50f72ca

File tree

1 file changed

+7
-3
lines changed
  • src/internal/vendor/react-keyed-flatten-children

1 file changed

+7
-3
lines changed

src/internal/vendor/react-keyed-flatten-children/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
// Vendored from [email protected] (MIT License)
5-
// Original source: https://github.com/grrowl/react-keyed-flatten-children
5+
// Original source: https://github.com/grrowl/react-keyed-flatten-children/tree/120a286144c7fdc76b64daadaeae0df7d255b497
66

77
import { Children, cloneElement, isValidElement, ReactElement, ReactNode } from 'react';
88

@@ -40,7 +40,11 @@ function isFragmentWithChildren(node: unknown): node is ReactElement<{ children:
4040
return isFragment(node);
4141
}
4242

43-
export default function flattenChildren(children: ReactNode, depth = 0, keys: (string | number)[] = []): ReactNode[] {
43+
export default function flattenChildren(
44+
children: ReactNode,
45+
depth: number = 0,
46+
keys: (string | number)[] = []
47+
): ReactNode[] {
4448
return Children.toArray(children).reduce((acc: ReactNode[], node, nodeIndex) => {
4549
if (isFragmentWithChildren(node)) {
4650
acc.push(...flattenChildren(node.props.children, depth + 1, keys.concat(node.key || nodeIndex)));
@@ -50,7 +54,7 @@ export default function flattenChildren(children: ReactNode, depth = 0, keys: (s
5054
key: keys.concat(String(node.key)).join('.'),
5155
})
5256
);
53-
} else if (typeof node === 'string' || typeof node === 'number') {
57+
} else if (typeof node === 'string' || typeof node === 'number' || typeof node === 'bigint') {
5458
acc.push(node);
5559
}
5660
return acc;

0 commit comments

Comments
 (0)