Skip to content

Commit 7790ab5

Browse files
committed
Review
1 parent c8ab464 commit 7790ab5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/Architecture.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Communicating between components is a common problem in React applications, espe
278278

279279
Whenever a react-admin component fetches data or defines a callback, the component creates a context and puts the data and callback in it.
280280

281-
For instance, the `<Admin>` component creates an `I18NProviderContext`, which exposes the `translate` function. All components in the application can use the `useTranslate` hok, which reads the `I18NProviderContext`, to translate their labels and messages.
281+
For instance, the `<Admin>` component creates an `I18NProviderContext`, which exposes the `translate` function. All components in the application can use the `useTranslate` hook, which reads the `I18NProviderContext`, to translate their labels and messages.
282282

283283
```jsx
284284
import { useTranslate } from 'react-admin';
@@ -298,7 +298,7 @@ import { useRecordContext } from 'react-admin';
298298
import { MapContainer, TileLayer, Marker } from 'react-leaflet';
299299

300300
const LocationField = ({ source }) => {
301-
const record = useRecordContext(props);
301+
const record = useRecordContext(props); // use the RecordContext created by <Show>
302302
if (!record) return null;
303303

304304
return (
@@ -313,7 +313,7 @@ const LocationField = ({ source }) => {
313313
};
314314

315315
const StoreShowPage = () => (
316-
<Show>
316+
<Show> {/* create a RecordContext */}
317317
<SimpleShowLayout>
318318
<TextField source="name" />
319319
<LocationField source="location" />
@@ -326,6 +326,8 @@ This simple approach removes the need for a dependency injection system.
326326

327327
So when you write a component that need to access data or callbacks defined higher in the render tree, you can always find a context to get it.
328328

329+
Contexts are one of the key concepts in React Admin. If you are not familiar with them, do not hesitate to read the [React documentation on Context](https://react.dev/learn/passing-data-deeply-with-context).
330+
329331
## User Experience Is King
330332

331333
React-admin has two sets of users:

0 commit comments

Comments
 (0)