diff --git a/docs/Tutorial.md b/docs/Tutorial.md
index 08daf61707d..31565b98a9e 100644
--- a/docs/Tutorial.md
+++ b/docs/Tutorial.md
@@ -87,7 +87,7 @@ That's enough for react-admin to render an empty app and confirm that the setup
Also, you should change the default Vite CSS file to look like this:
```css
-// in src/index.css
+/* in src/index.css */
body {
margin: 0;
}
@@ -459,8 +459,8 @@ import { UserList } from "./users";
const App = () => (
-+
-
+
++
);
@@ -755,7 +755,7 @@ export const PostEdit = () => (
[](./img/tutorial_post_title.png)
-This component uses the same `useRecordContext` hook as the custom `` commponent described earlier.
+This component uses the same `useRecordContext` hook as the custom `` component described earlier.
As users can access the post editing page directly by its url, the `` component may render *without a record* while the `` component is fetching it. That's why you must always check that the `record` returned by `useRecordContext` is defined before using it - as in `PostTitle` above.
@@ -845,8 +845,10 @@ For this tutorial, since there is no public authentication API, we can use a fak
The `authProvider` must expose 5 methods, each returning a `Promise`:
-```jsx
+```js
// in src/authProvider.ts
+
+// TypeScript users must reference the type: `AuthProvider`
export const authProvider = {
// called when the user attempts to log in
login: ({ username }) => {
@@ -924,13 +926,15 @@ React-admin calls the Data Provider with one method for each of the actions of t
The code for a Data Provider for the `my.api.url` API is as follows:
```js
+// in src/dataProvider.ts
import { fetchUtils } from "react-admin";
import { stringify } from "query-string";
const apiUrl = 'https://my.api.com/';
const httpClient = fetchUtils.fetchJson;
-export const dataProvider= {
+// TypeScript users must reference the type `DataProvider`
+export const dataProvider = {
getList: (resource, params) => {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
@@ -943,7 +947,7 @@ export const dataProvider= {
return httpClient(url).then(({ headers, json }) => ({
data: json,
- total: parseInt(headers.get('content-range').split('/').pop(), 10),
+ total: parseInt((headers.get('content-range') || "0").split('/').pop() || 0, 10),
}));
},
@@ -975,7 +979,7 @@ export const dataProvider= {
return httpClient(url).then(({ headers, json }) => ({
data: json,
- total: parseInt(headers.get('content-range').split('/').pop(), 10),
+ total: parseInt((headers.get('content-range') || "0").split('/').pop() || 0, 10),
}));
},
@@ -1040,4 +1044,4 @@ React-admin was built with customization in mind. You can replace any react-admi
Now that you've completed the tutorial, continue your journey with [the Features chapter](./Features.md), which lists all the features of react-admin.
-**Tip**: To help you close the gap between theoritical knowledge and practical experience, take advantage of the react-admin [Demos](./Demos.md). They are great examples of how to use react-admin in a real world application. They also show the best practices for going beyond simple CRUD apps.
+**Tip**: To help you close the gap between theoretical knowledge and practical experience, take advantage of the react-admin [Demos](./Demos.md). They are great examples of how to use react-admin in a real world application. They also show the best practices for going beyond simple CRUD apps.
diff --git a/examples/tutorial/src/authProvider.ts b/examples/tutorial/src/authProvider.ts
index 8d632129589..1b24e7196a0 100644
--- a/examples/tutorial/src/authProvider.ts
+++ b/examples/tutorial/src/authProvider.ts
@@ -1,4 +1,6 @@
-export const authProvider = {
+import { AuthProvider } from 'react-admin';
+
+export const authProvider: AuthProvider = {
// called when the user attempts to log in
login: ({ username }: { username: string }) => {
localStorage.setItem('username', username);