@@ -104,36 +104,37 @@ import { WithListContext } from 'react-admin';
104104import { Chip , Stack , Typography } from ' @mui/material' ;
105105
106106const TagList = ({data, isPending}) => (
107- < WithListContext
108- data= {data}
109- isPending= {isPending}
107+ < WithListContext
108+ data= {data}
109+ isPending= {isPending}
110110 loading= {< Typography> Loading tags... < / Typography> }
111- empty= {< Typography> No associated tags< / Typography> }
112- render= {({ data }) => (
113- < Stack direction= " row" spacing= {1 }>
114- {data .map (tag => (
115- < Chip key= {tag .id } label= {tag .name } / >
116- ))}
117- < / Stack>
118- )}
119- / >
111+ empty= {< Typography> No associated tags< / Typography> }
112+ render= {({ data }) => (
113+ < Stack direction= " row" spacing= {1 }>
114+ {data .map (tag => (
115+ < Chip key= {tag .id } label= {tag .name } / >
116+ ))}
117+ < / Stack>
118+ )}
119+ / >
120120);
121121```
122122
123123## Props
124124
125125` <WithListContext> ` accepts a single ` render ` prop, which should be a function.
126126
127- | Prop | Required | Type | Default | Description |
128- | ----------------| ----------| ----------------| ---------| -----------------------------------------------------------|
129- | ` data ` | Optional | ` RecordType[] ` | | The list data in standalone usage. |
130- | ` empty ` | Optional | ` ReactNode ` | | The component to display when the data is empty. |
131- | ` error ` | Optional | ` Error ` | | The error in standalone usage. |
132- | ` errorElement ` | Optional | ` ReactNode ` | | The component to display in case of error. |
133- | ` isPending ` | Optional | ` boolean ` | | Determine if the list is loading in standalone usage. |
134- | ` loading ` | Optional | ` ReactNode ` | | The component to display while checking authorizations. |
135- | ` render ` | Required | ` function ` | | The function to render the data |
136- | ` total ` | Optional | ` number ` | | The total number of data in the list in standalone usage. |
127+ | Prop | Required | Type | Default | Description |
128+ | ----------------| ----------| ----------------| ---------| -------------------------------------------------------------------------------------------|
129+ | ` data ` | Optional | ` RecordType[] ` | | The list data in standalone usage. |
130+ | ` empty ` | Optional | ` ReactNode ` | | The component to display when the data is empty. |
131+ | ` error ` | Optional | ` Error ` | | The error in standalone usage. |
132+ | ` errorElement ` | Optional | ` ReactNode ` | | The component to display in case of error. |
133+ | ` isPending ` | Optional | ` boolean ` | | Determine if the list is loading in standalone usage. |
134+ | ` loading ` | Optional | ` ReactNode ` | | The component to display while checking authorizations. |
135+ | ` offline ` | Optional | ` ReactNode ` | | The component to display when there is no connectivity to load data and no data in cache. |
136+ | ` render ` | Required | ` function ` | | The function to render the data |
137+ | ` total ` | Optional | ` number ` | | The total number of data in the list in standalone usage. |
137138
138139## ` empty `
139140
@@ -143,18 +144,18 @@ If `empty` is not provided, the render function will be called with empty data.
143144
144145``` jsx
145146< WithListContext
146- empty= {< p> no books< / p> }
147- render= {({ data }) => (
148- < ul>
149- {data .map (book => (
150- < li key= {book .id }>
151- < i> {book .title }< / i> , published on
152- {book .published_at }
153- < / li>
154- ))}
155- < / ul>
156- )}
157- loading= {< p> Loading... < / p> }
147+ empty= {< p> no books< / p> }
148+ render= {({ data }) => (
149+ < ul>
150+ {data .map (book => (
151+ < li key= {book .id }>
152+ < i> {book .title }< / i> , published on
153+ {book .published_at }
154+ < / li>
155+ ))}
156+ < / ul>
157+ )}
158+ loading= {< p> Loading... < / p> }
158159/ >
159160```
160161
@@ -189,17 +190,39 @@ If `loading` is not provided, the render function will be called with `isPending
189190
190191``` jsx
191192< WithListContext
192- loading= {< p> loading... < / p> }
193- render= {({ data }) => (
194- < ul>
195- {data .map (book => (
196- < li key= {book .id }>
197- < i> {book .title }< / i> , published on
198- {book .published_at }
199- < / li>
200- ))}
201- < / ul>
202- )}
193+ loading= {< p> loading... < / p> }
194+ render= {({ data }) => (
195+ < ul>
196+ {data .map (book => (
197+ < li key= {book .id }>
198+ < i> {book .title }< / i> , published on
199+ {book .published_at }
200+ < / li>
201+ ))}
202+ < / ul>
203+ )}
204+ / >
205+ ```
206+
207+ ## ` offline `
208+
209+ Use ` offline ` to display a component when there is no connectivity to load data and no data in cache.
210+
211+ If ` offline ` is not provided, the render function will be called with ` isPaused ` as true and no data.
212+
213+ ``` jsx
214+ < WithListContext
215+ offline= {< p> Offline< / p> }
216+ render= {({ data }) => (
217+ < ul>
218+ {data .map (book => (
219+ < li key= {book .id }>
220+ < i> {book .title }< / i> , published on
221+ {book .published_at }
222+ < / li>
223+ ))}
224+ < / ul>
225+ )}
203226/ >
204227```
205228
0 commit comments