Skip to content

Commit 3efe54b

Browse files
authored
Merge pull request #8577 from harryghgim/patch-1
update Upgrade.md
2 parents 46cc493 + 6cf261d commit 3efe54b

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

docs/Upgrade.md

+59-59
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,17 @@ Note that `<CustomRoutes>` handles `null` elements and fragments correctly, so y
423423
}
424424
```
425425

426-
See [https://reactrouter.com/docs/en/v6/upgrading/v5#advantages-of-route-element](https://reactrouter.com/docs/en/v6/upgrading/v5#advantages-of-route-element) for more details about the new `<Route>` element
426+
See [https://reactrouter.com/en/6.6.2/upgrading/v5#advantages-of-route-element](https://reactrouter.com/en/6.6.2/upgrading/v5#advantages-of-route-element) for more details about the new `<Route>` element
427427

428428
### Use `useNavigate` instead of `useHistory`
429429

430-
See [https://reactrouter.com/docs/en/v6/upgrading/v5#use-usenavigate-instead-of-usehistory](https://reactrouter.com/docs/en/v6/upgrading/v5#use-usenavigate-instead-of-usehistory) to upgrade.
430+
See [https://reactrouter.com/en/v6/upgrading/v5#use-usenavigate-instead-of-usehistory](https://reactrouter.com/en/v6/upgrading/v5#use-usenavigate-instead-of-usehistory) to upgrade.
431431

432432
### Change The `<Route>` Syntax
433433

434434
If your admin contains components that add new sub routes (like react-admin's `<TabbedForm>` and `<TabbedShowLayout>`), you'll need to update the `<Route>` syntax.
435435

436-
See [https://reactrouter.com/docs/en/v6/upgrading/v5](https://reactrouter.com/docs/en/v6/upgrading/v5) for details.
436+
See [https://reactrouter.com/en/v6/upgrading/v5](https://reactrouter.com/en/v6/upgrading/v5) for details.
437437

438438
### Using A Custom History
439439

@@ -1531,7 +1531,7 @@ The same happens for `<Datagrid>`: when used in standalone, it used to accept a
15311531
<TextField source="year" />
15321532
</Datagrid>
15331533
```
1534-
{% raw %}
1534+
{% endraw %}
15351535

15361536
### `setSort()` Signature Changed
15371537

@@ -2014,7 +2014,7 @@ export const PostEdit = () => (
20142014
);
20152015
```
20162016

2017-
The `<Toolbar>` component used to receive the `width` prop also, that allowed to display the mobile or desktop version depending on its value. This is handle internally in version 4 and you can safely remove this prop.
2017+
The `<Toolbar>` component used to receive the `width` prop also, that allowed to display the mobile or desktop version depending on its value. This is handled internally in version 4 and you can safely remove this prop.
20182018

20192019
```diff
20202020
import { Toolbar } from 'react-admin';
@@ -2214,14 +2214,14 @@ The `save` function signature no longer takes a redirection side effect as the s
22142214
const MyCustomCreate = () => {
22152215
const createControllerProps = useCreateController();
22162216
const notify = useNotify();
2217-
+ const redirect = useRedirect();
2217+
+ const redirect = useRedirect();
22182218

22192219
const handleSubmit = (values) => {
22202220
- createControllerProps.save(values, 'show', {
22212221
+ createControllerProps.save(values, {
22222222
onSuccess: (data) => {
22232223
notify('Success');
2224-
+ redirect('show', '/posts', data.id);
2224+
+ redirect('show', '/posts', data.id);
22252225
}
22262226
})
22272227
}
@@ -2238,7 +2238,7 @@ const MyCustomCreate = () => {
22382238

22392239
### `<FormContext>`, `<FormContextProvider>` and `useFormContext` Have Been Removed
22402240

2241-
These changes only concerns you if you had custom forms not built with `<FormWithRedirect>`, or custom components relying on the form groups management (accordions or collapsible sections for instance).
2241+
These changes only concern you if you had custom forms not built with `<FormWithRedirect>`, or custom components relying on the form groups management (accordions or collapsible sections for instance).
22422242

22432243
As the `save` and `saving` properties are already available through the `<SaveContext>` component and its `useSaveContext` hook, we removed the `<FormContext>`, `<FormContextProvider>` components as well the `useFormContext` hook. The functions around form groups management have been extracted into the `<FormGroupsProvider>` component:
22442244

@@ -2285,21 +2285,21 @@ If you had the `redirect` prop set on the `SaveButton`, provide a `onSuccess` pr
22852285

22862286
```diff
22872287
const PostCreateToolbar = props => {
2288-
+ const notify = useNotify();
2289-
+ const redirect = useRedirect();
2288+
+ const notify = useNotify();
2289+
+ const redirect = useRedirect();
22902290
return (
22912291
<Toolbar {...props}>
22922292
<SaveButton
22932293
label="post.action.save_and_edit"
2294-
- redirect="edit"
2295-
+ onSuccess={data => {
2296-
+ notify('ra.notification.updated', {
2297-
+ type: 'info',
2298-
+ messageArgs: { smart_count: 1 },
2299-
+ undoable: true,
2300-
+ });
2301-
+ redirect('edit', '/posts', data.id)
2302-
+ }}
2294+
- redirect="edit"
2295+
+ onSuccess={data => {
2296+
+ notify('ra.notification.updated', {
2297+
+ type: 'info',
2298+
+ messageArgs: { smart_count: 1 },
2299+
+ undoable: true,
2300+
+ });
2301+
+ redirect('edit', '/posts', data.id)
2302+
+ }}
23032303
/>
23042304
</Toolbar>
23052305
);
@@ -2403,7 +2403,7 @@ const PostShow = () => (
24032403

24042404
### `addLabel` Prop No Longer Considered For Show Labelling
24052405

2406-
`<SimpleShowLayout>` and `<TabbedShowLayout>` used to look for an `addLabel` prop to decide whether they needed to add a label or not. this relied on `defaultProps`, which will soon be removed from React.
2406+
`<SimpleShowLayout>` and `<TabbedShowLayout>` used to look for an `addLabel` prop to decide whether they needed to add a label or not. This relied on `defaultProps`, which will soon be removed from React.
24072407

24082408
The Show layout components now render a label for their children as soon as they have a `source` or a `label` prop. If you don't want a field to have a label in the show view, pass the `label={false}` prop.
24092409

@@ -2494,33 +2494,33 @@ export default LatLngInput;
24942494

24952495
Just like all inputs, `useInput` now only accept `defaultValue` and will ignore `initialValue`.
24962496

2497-
Besides, `useInput` used to return `final-form` properties such as `input ` and `meta`. It now returns `field`, `fieldState` and `formState` (see https://react-hook-form.com/api/usecontroller).
2497+
Besides, `useInput` used to return `final-form` properties such as `input` and `meta`. It now returns `field`, `fieldState` and `formState` (see https://react-hook-form.com/api/usecontroller).
24982498

2499-
Note that the `error` returned by `fieldState` is a not just a simple string anymore but an object with a `message` property.
2499+
Note that the `error` returned by `fieldState` is not just a simple string anymore but an object with a `message` property.
25002500

25012501
```diff
25022502
import TextField from 'mui/material/TextField';
25032503
import { useInput, required } from 'react-admin';
25042504

25052505
const MyInput = ({ helperText, ...props }) => {
25062506
const {
2507-
- input,
2508-
+ field,
2509-
- meta: { touched, error },
2510-
+ fieldState: { isTouched, invalid, error },
2511-
+ formState: { isSubmitted }
2507+
- input,
2508+
+ field,
2509+
- meta: { touched, error },
2510+
+ fieldState: { isTouched, invalid, error },
2511+
+ formState: { isSubmitted }
25122512
isRequired
25132513
} = useInput(props);
25142514

25152515
return (
25162516
<TextField
2517-
- {...input}
2518-
+ {...field}
2517+
- {...input}
2518+
+ {...field}
25192519
label={props.label}
2520-
- error={touched && !!error}
2521-
+ error={(isTouched || isSubmitted) && invalid}
2522-
- helperText={touched && !!error ? error : helperText}
2523-
+ helperText={(isTouched || isSubmitted) && invalid ? error?.message : helperText}
2520+
- error={touched && !!error}
2521+
+ error={(isTouched || isSubmitted) && invalid}
2522+
- helperText={touched && !!error ? error : helperText}
2523+
+ helperText={(isTouched || isSubmitted) && invalid ? error?.message : helperText}
25242524
required={isRequired}
25252525
{...rest}
25262526
/>
@@ -2529,8 +2529,8 @@ const MyInput = ({ helperText, ...props }) => {
25292529

25302530
const UserForm = () => (
25312531
<SimpleForm>
2532-
- <MyInput initialValue="John" />
2533-
+ <MyInput defaultValue="John" />
2532+
- <MyInput initialValue="John" />
2533+
+ <MyInput defaultValue="John" />
25342534
</SimpleForm>
25352535
)
25362536
```
@@ -2545,7 +2545,7 @@ If you used the `addLabel` prop to hide inputs label by passing `false`, you can
25452545

25462546
We migrated both the `AutocompleteInput` and `AutocompleteArrayInput` components so that they leverage MUI [`<Autocomplete>`](https://mui.com/components/autocomplete/). If you relied on [Downshift](https://www.downshift-js.com/) options, you'll have to update your component.
25472547

2548-
Besides, some props supported by the previous implementation aren't anymore:
2548+
Besides, some props aren't available anymore:
25492549
- `allowDuplicates`: This is not supported by MUI Autocomplete.
25502550
- `clearAlwaysVisible`: the clear button is now always visible, either while hovering the input or when it has focus. You can hide it using the `<Autocomplete>` `disableClearable` prop though.
25512551
- `resettable`: Removed for the same reason as `clearAlwaysVisible`
@@ -2625,25 +2625,25 @@ import {
26252625
const MyRichTextInput = (props) => (
26262626
<RichTextInput
26272627
{...props}
2628-
- configureQuill={configureQuill}
2629-
+ toolbar={
2630-
+ <RichTextInputToolbar>
2631-
+ <LevelSelect size={size} />
2632-
+ <FormatButtons size={size} />
2633-
+ <AlignmentButtons {size} />
2634-
+ <ListButtons size={size} />
2635-
+ <LinkButtons size={size} />
2636-
+ <QuoteButtons size={size} />
2637-
+ <ClearButtons size={size} />
2638-
+ <ToggleButton
2639-
+ aria-label="Add a smile"
2640-
+ title="Add a smile"
2641-
+ onClick={() => editor.insertContent(':-)')}
2642-
+ >
2643-
+ <Remove fontSize="inherit" />
2644-
+ </ToggleButton>
2645-
+ </RichTextInputToolbar>
2646-
}
2628+
- configureQuill={configureQuill}
2629+
+ toolbar={
2630+
+ <RichTextInputToolbar>
2631+
+ <LevelSelect size={size} />
2632+
+ <FormatButtons size={size} />
2633+
+ <AlignmentButtons {size} />
2634+
+ <ListButtons size={size} />
2635+
+ <LinkButtons size={size} />
2636+
+ <QuoteButtons size={size} />
2637+
+ <ClearButtons size={size} />
2638+
+ <ToggleButton
2639+
+ aria-label="Add a smile"
2640+
+ title="Add a smile"
2641+
+ onClick={() => editor.insertContent(':-)')}
2642+
+ >
2643+
+ <Remove fontSize="inherit" />
2644+
+ </ToggleButton>
2645+
+ </RichTextInputToolbar>
2646+
}
26472647
/>
26482648
}
26492649
```
@@ -2699,10 +2699,10 @@ It is now the responsibility of the child input to call the `setFilters` functio
26992699
const UserListFilter = [
27002700
<ReferenceInput
27012701
source="email"
2702-
- filterToQuery={search => ({ email: search })}
2702+
- filterToQuery={search => ({ email: search })}
27032703
>
2704-
- <AutocompleteInput />
2705-
+ <AutocompleteInput filterToQuery={search => ({ email: search })} />
2704+
- <AutocompleteInput />
2705+
+ <AutocompleteInput filterToQuery={search => ({ email: search })} />
27062706
</ReferenceInput>
27072707
]
27082708
```
@@ -2775,7 +2775,7 @@ const MyCustomInput = () => {
27752775
+ setPerPage,
27762776
+ setSort,
27772777
+ sort,
2778-
+ } = useChoicesContext();
2778+
+ } = useChoicesContext();
27792779
return // ...
27802780
}
27812781
```

0 commit comments

Comments
 (0)