@@ -13,14 +13,15 @@ import {
1313 useThemeProps ,
1414} from '@mui/material/styles' ;
1515import {
16- ListIterator ,
1716 type RaRecord ,
17+ RecordContextProvider ,
1818 sanitizeListRestProps ,
1919 useGetRecordRepresentation ,
2020 useListContextWithProps ,
2121 useRecordContext ,
2222 useResourceContext ,
2323 useTranslate ,
24+ WithListContext ,
2425} from 'ra-core' ;
2526import * as React from 'react' ;
2627import { isValidElement , type ReactElement } from 'react' ;
@@ -100,6 +101,8 @@ export const SimpleList = <RecordType extends RaRecord = any>(
100101 const { data, isPending, total } =
101102 useListContextWithProps < RecordType > ( props ) ;
102103
104+ console . log ( 'SimpleList' ) ;
105+
103106 if ( isPending === true ) {
104107 return (
105108 < SimpleListLoading
@@ -122,31 +125,40 @@ export const SimpleList = <RecordType extends RaRecord = any>(
122125
123126 return (
124127 < Root className = { className } { ...sanitizeListRestProps ( rest ) } >
125- < ListIterator < RecordType >
126- data = { data }
127- total = { total }
128- render = { ( record , rowIndex ) => (
129- < SimpleListItem
130- key = { record . id }
131- rowIndex = { rowIndex }
132- linkType = { linkType }
133- rowClick = { rowClick }
134- rowSx = { rowSx }
135- rowStyle = { rowStyle }
136- resource = { resource }
137- >
138- < SimpleListItemContent
139- leftAvatar = { leftAvatar }
140- leftIcon = { leftIcon }
141- primaryText = { primaryText }
142- rightAvatar = { rightAvatar }
143- rightIcon = { rightIcon }
144- secondaryText = { secondaryText }
145- tertiaryText = { tertiaryText }
146- rowIndex = { rowIndex }
147- />
148- </ SimpleListItem >
149- ) }
128+ < WithListContext < RecordType >
129+ render = { ( { isPending, data } ) =>
130+ ! isPending && (
131+ < >
132+ { data ?. map ( ( record , rowIndex ) => (
133+ < RecordContextProvider
134+ value = { record }
135+ key = { record . id }
136+ >
137+ < SimpleListItem
138+ key = { record . id }
139+ rowIndex = { rowIndex }
140+ linkType = { linkType }
141+ rowClick = { rowClick }
142+ rowSx = { rowSx }
143+ rowStyle = { rowStyle }
144+ resource = { resource }
145+ >
146+ < SimpleListItemContent
147+ leftAvatar = { leftAvatar }
148+ leftIcon = { leftIcon }
149+ primaryText = { primaryText }
150+ rightAvatar = { rightAvatar }
151+ rightIcon = { rightIcon }
152+ secondaryText = { secondaryText }
153+ tertiaryText = { tertiaryText }
154+ rowIndex = { rowIndex }
155+ />
156+ </ SimpleListItem >
157+ </ RecordContextProvider >
158+ ) ) }
159+ </ >
160+ )
161+ }
150162 />
151163 </ Root >
152164 ) ;
0 commit comments