diff --git a/packages/@react-facet/core/src/components/Map.tsx b/packages/@react-facet/core/src/components/Map.tsx index ed2a843..9653396 100644 --- a/packages/@react-facet/core/src/components/Map.tsx +++ b/packages/@react-facet/core/src/components/Map.tsx @@ -6,13 +6,13 @@ import { EqualityCheck, Facet, NO_VALUE } from '../types' export type MapProps = { array: Facet - children: (item: Facet, index: number, count: number) => ReactElement | null + children: (item: Facet, index: number, length: number) => ReactElement | null equalityCheck?: EqualityCheck } export const Map = ({ array, children, equalityCheck }: MapProps) => { - const countValue = useFacetUnwrap(useFacetMap((array) => array.length, [], [array])) - const countNumber = countValue !== NO_VALUE ? countValue : 0 + const lengthValue = useFacetUnwrap(useFacetMap((array) => array.length, [], [array])) + const lengthNumber = lengthValue !== NO_VALUE ? lengthValue : 0 return ( <> @@ -23,14 +23,14 @@ export const Map = ({ array, children, equalityCheck }: MapProps) => { key={index} arrayFacet={array} index={index} - count={countNumber} + length={lengthNumber} equalityCheck={equalityCheck} children={children} /> ) : ( - key={index} arrayFacet={array} index={index} count={countNumber} children={children} /> + key={index} arrayFacet={array} index={index} length={lengthNumber} children={children} /> ), - countNumber, + lengthNumber, )} ) @@ -39,12 +39,12 @@ export const Map = ({ array, children, equalityCheck }: MapProps) => { type MapChildMemoProps = { arrayFacet: Facet index: number - count: number - children: (item: Facet, index: number, count: number) => ReactElement | null + length: number + children: (item: Facet, index: number, length: number) => ReactElement | null equalityCheck: EqualityCheck } -const MapChildMemo = ({ arrayFacet, index, count, children, equalityCheck }: MapChildMemoProps) => { +const MapChildMemo = ({ arrayFacet, index, length, children, equalityCheck }: MapChildMemoProps) => { const childFacet = useFacetMemo( (array) => { if (index < array.length) return array[index] @@ -54,17 +54,17 @@ const MapChildMemo = ({ arrayFacet, index, count, children, equalityCheck }: [arrayFacet], equalityCheck, ) - return children(childFacet, index, count) + return children(childFacet, index, length) } type MapChildProps = { arrayFacet: Facet index: number - count: number - children: (item: Facet, index: number, count: number) => ReactElement | null + length: number + children: (item: Facet, index: number, length: number) => ReactElement | null } -const MapChild = ({ arrayFacet, index, count, children }: MapChildProps) => { +const MapChild = ({ arrayFacet, index, length, children }: MapChildProps) => { const childFacet = useFacetMap( (array) => { if (index < array.length) return array[index] @@ -74,7 +74,7 @@ const MapChild = ({ arrayFacet, index, count, children }: MapChildProps) [arrayFacet], ) - return children(childFacet, index, count) + return children(childFacet, index, length) } interface TimesFn {