MCPcopy Create free account
hub / github.com/bvaughn/react-window / encodeChildren

Function encodeChildren

integrations/tests/src/utils/serializer/encode.ts:22–59  ·  view source on GitHub ↗
(children: ReactElement<unknown>[])

Source from the content-addressed store, hash-verified

20}
21
22function encodeChildren(children: ReactElement<unknown>[]): EncodedElement[] {
23 const elements: EncodedElement[] = [];
24
25 children.forEach((current) => {
26 if (!current) {
27 return;
28 }
29
30 switch (current.type) {
31 case List: {
32 elements.push(
33 encodeList(current as ReactElement<ListProps<RowComponentData>>)
34 );
35 break;
36 }
37 case RowComponent: {
38 elements.push(
39 encodeRowComponent(
40 current as ReactElement<RowComponentProps<RowComponentData>>
41 )
42 );
43 break;
44 }
45 default: {
46 if (typeof current === "object") {
47 const { children } = current.props as TextProps;
48 if (typeof children === "string") {
49 elements.push(encodeTextChild(current as ReactElement<TextProps>));
50 } else {
51 console.warn("Could not encode type:", current);
52 }
53 }
54 }
55 }
56 });
57
58 return elements;
59}
60
61function encodeList(
62 element: ReactElement<ListProps<RowComponentData>>

Callers 1

encodeFunction · 0.85

Calls 3

encodeListFunction · 0.85
encodeRowComponentFunction · 0.85
encodeTextChildFunction · 0.85

Tested by

no test coverage detected