Skip to content

Commit cd6582e

Browse files
committed
Applied review
1 parent d0a7d06 commit cd6582e

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

docs/Features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ And last but not least, react-admin provides a **lock mechanism** to prevent two
10961096

10971097
A user can lock a resource, either by voluntarily asking for a lock or by editing a resource. When a resource is locked, other users can't edit it. When the lock is released, other users can edit the resource again.
10981098

1099-
```jsx
1099+
```tsx
11001100
export const NewMessageForm = () => {
11011101
const [create, { isLoading: isCreating }] = useCreate();
11021102
const record = useRecordContext();
@@ -1106,7 +1106,7 @@ export const NewMessageForm = () => {
11061106
const isFormDisabled = lock && lock.identity !== identity?.id;
11071107

11081108
const [doLock] = useLockOnCall({ resource: 'tickets' });
1109-
const handleSubmit = (values) => {
1109+
const handleSubmit = (values: any) => {
11101110
/* ... */
11111111
};
11121112

docs/Inputs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ form state value --> format --> form input value (string)
171171

172172
**Tip:** By default, react-admin inputs have the following `format` function, which turns any `null` or `undefined` value into an empty string. This is to avoid warnings about controlled/uncontrolled input components:
173173

174-
```js
175-
const defaultFormat = (value) => value == null ? '' : value;
174+
```ts
175+
const defaultFormat = (value: any) => value == null ? '' : value;
176176
```
177177

178178
## `fullWidth`

docs/PredictiveTextInput.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ If you rely on another API, you'll need to fetch it yourself.
338338

339339
Finally, you don't need a completion API to use `<PredictiveTextInput>` in simple cases. For example, here is an implementation that deduces an email address from the first and last name directly in the browser:
340340

341-
```jsx
341+
```tsx
342342
const getCompletionLocal = async ({ prompt = '' }) => {
343343
const { key, value, record } = getParamsFromPrompt(prompt);
344344
if (key === 'email') {
@@ -391,7 +391,7 @@ const getParamsForPrompt = (prompt) => {
391391
const [key, value] = line.split(':');
392392
acc[key] = value;
393393
return acc;
394-
}, {});
394+
}, {} as any);
395395
return { key, value, record };
396396
}
397397
```

docs/Realtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ And last but not least, ra-realtime provides a **lock mechanism** to prevent two
141141

142142
A user can lock a resource, either by voluntarily asking for a lock or by editing a resource. When a resource is locked, other users can't edit it. When the lock is released, other users can edit the resource again.
143143

144-
```jsx
144+
```tsx
145145
export const NewMessageForm = () => {
146146
const [create, { isLoading: isCreating }] = useCreate();
147147
const record = useRecordContext();
@@ -151,7 +151,7 @@ export const NewMessageForm = () => {
151151
const isFormDisabled = lock && lock.identity !== identity?.id;
152152

153153
const [doLock] = useLockOnCall({ resource: 'tickets' });
154-
const handleSubmit = (values) => {
154+
const handleSubmit = (values: any) => {
155155
/* ... */
156156
};
157157

docs/Search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ export const App = () => (
128128

129129
If you're using [the `<ContainerLayout>` component](./ContainerLayout.md), you can use the `<Search>` component directly in the `toolbar` prop:
130130

131-
```jsx
131+
```tsx
132132
// in src/MyLayout.jsx
133133
import { ContainerLayout } from "@react-admin/ra-navigation";
134134
import { Search } from "@react-admin/ra-search";
135135

136-
const MyLayout = (props) => (
136+
const MyLayout = (props: any) => (
137137
<ContainerLayout {...props} maxWidth="xl" toolbar={<Search />} />
138138
);
139139
```

docs/useSubscribeToRecord.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The hook expects a callback function as its only argument, as it guesses the rec
2020

2121
For instance, the following component displays a dialog when the record is updated by someone else:
2222

23-
```jsx
23+
```tsx
2424
import { useState } from 'react';
2525
import { useEditContext, useFormContext } from 'react-admin';
2626
import {
@@ -48,7 +48,7 @@ const WarnWhenUpdatedBySomeoneElse = () => {
4848
formState: { isDirty },
4949
} = useFormContext();
5050

51-
useSubscribeToRecord((event) => {
51+
useSubscribeToRecord((event: Event) => {
5252
if (event.type === 'edited') {
5353
if (isDirty) {
5454
setOpen(true);
@@ -124,14 +124,14 @@ useSubscribeToRecord(event => { /* ... */ }, 'posts', 123);
124124

125125
Whenever an event is published on the `resource/[resource]/[recordId]` topic, the function passed as the first argument will be called with the event as a parameter.
126126

127-
```jsx
127+
```tsx
128128
const [open, setOpen] = useState(false);
129129
const [author, setAuthor] = useState<string | null>(null);
130130
const { refetch } = useEditContext();
131131
const {
132132
formState: { isDirty },
133133
} = useFormContext();
134-
useSubscribeToRecord((event) => {
134+
useSubscribeToRecord((event: Event) => {
135135
if (event.type === 'edited') {
136136
if (isDirty) {
137137
setOpen(true);
@@ -145,7 +145,7 @@ useSubscribeToRecord((event) => {
145145

146146
**Tip**: Memoize the callback using `useCallback` to avoid unnecessary subscriptions/unsubscriptions.
147147

148-
```jsx
148+
```tsx
149149
const [open, setOpen] = useState(false);
150150
const [author, setAuthor] = useState<string | null>(null);
151151
const { refetch } = useEditContext();
@@ -154,7 +154,7 @@ const {
154154
} = useFormContext();
155155

156156
const handleEvent = useCallback(
157-
(event) => {
157+
(event: Event) => {
158158
if (event.type === 'edited') {
159159
if (isDirty) {
160160
setOpen(true);
@@ -172,8 +172,8 @@ useSubscribeToRecord(handleEvent);
172172

173173
Just like for `useSubscribe`, the callback function receives an `unsubscribe` callback as its second argument. You can call it to unsubscribe from the topic after receiving a specific event.
174174

175-
```jsx
176-
useSubscribeToRecord((event, unsubscribe) => {
175+
```tsx
176+
useSubscribeToRecord((event: Event, unsubscribe) => {
177177
if (event.type === 'deleted') {
178178
// do something
179179
unsubscribe();

0 commit comments

Comments
 (0)