Add render prop support to ReferenceManyCount#11266
Conversation
|
Thanks for your PR. Now that I see the result, I think that supporting I think that using a <ReferenceManyCount
reference="comments"
target="post_id"
render=({ total }) => new Intl.NumberFormat("de-DE").format(total)}
/>If you want to use a Field component there, you can just pass the record explicitly (all fields compmonents support it): <ReferenceManyCount
reference="comments"
target="post_id"
render=({ total }) => <NumberField record={( total }} source="total" />}
/>Besides, this syntax is already familiar as it's used by |
|
Thanks for the guidance. I reworked the PR to use a render function instead of children/RecordContext, matching the RecordField/DataTable.Col style you suggested. The updated implementation passes { total } directly to render, updates both ReferenceManyCount and ReferenceManyCountBase docs/stories, and adds focused coverage for the render customization path. I also updated the PR title to reflect the render prop approach. |
Summary
ReferenceManyCountBaseto render custom children using a record context containingtotalReferenceManyCountchildren so fields likeNumberField source=totalcan format large countsFixes #11242
Tests
node .yarn\releases\yarn-4.0.2.cjs test-unit packages/ra-core/src/controller/field/ReferenceManyCountBase.spec.tsx packages/ra-ui-materialui/src/field/ReferenceManyCount.spec.tsxnode .yarn\releases\yarn-4.0.2.cjs exec eslint packages/ra-core/src/controller/field/ReferenceManyCountBase.tsx packages/ra-core/src/controller/field/ReferenceManyCountBase.stories.tsx packages/ra-core/src/controller/field/ReferenceManyCountBase.spec.tsx packages/ra-ui-materialui/src/field/ReferenceManyCount.tsx packages/ra-ui-materialui/src/field/ReferenceManyCount.stories.tsx packages/ra-ui-materialui/src/field/ReferenceManyCount.spec.tsxnode .yarn\releases\yarn-4.0.2.cjs workspace ra-core buildnode .yarn\releases\yarn-4.0.2.cjs workspace ra-ui-materialui build