You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/data/migration/migration-pickers-v7/migration-pickers-v7.md
+125-8
Original file line number
Diff line number
Diff line change
@@ -364,6 +364,19 @@ This change causes a few breaking changes:
364
364
);
365
365
```
366
366
367
+
- The component passed to the `layout` slot no longer receives the `value` prop, instead you can use the `usePickerContext` hook:
368
+
369
+
```diff
370
+
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
371
+
372
+
// This contains a small behavior change.
373
+
// If the picker receives an invalid date,
374
+
// the old value equals `null`.
375
+
// the new value equals the invalid date received.
376
+
-const { value } = props;
377
+
+const { value } = usePickerContext();
378
+
```
379
+
367
380
- The component passed to the `layout` slot no longer receives the `disabled` and `readOnly` props, instead you can use the `usePickerContext` hook:
368
381
369
382
```diff
@@ -376,7 +389,7 @@ This change causes a few breaking changes:
376
389
+const { readOnly } = usePickerContext();
377
390
```
378
391
379
-
- The component passed to the `layout` slot no longer receives an`isRtl` prop. If you need to access this information, you can use the `useRtl` hook from `@mui/system`:
392
+
- The component passed to the `layout` slot no longer receives the`isRtl` prop. If you need to access this information, you can use the `useRtl` hook from `@mui/system`:
380
393
381
394
```diff
382
395
+import { useRtl } from '@mui/system/RtlProvider';
@@ -398,7 +411,7 @@ This change causes a few breaking changes:
398
411
+const isLandscape = orientation === 'landscape';
399
412
```
400
413
401
-
- The component passed to the `layout` slot no longer receives a`wrapperVariant` prop, instead you can use the `usePickerContext` hook:
414
+
- The component passed to the `layout` slot no longer receives the`wrapperVariant` prop, instead you can use the `usePickerContext` hook:
402
415
403
416
```diff
404
417
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
@@ -422,7 +435,8 @@ This change causes a few breaking changes:
422
435
+const { onViewChange } = usePickerContext();
423
436
```
424
437
425
-
- The component passed to the `layout` slot no longer receives the `onClear`, `onSetToday`, `onAccept`, `onCancel`, `onOpen`, `onClose` and `onDismiss` props, instead you can use the `usePickerActionsContext` or the `usePickerContext` hooks:
438
+
- The component passed to the `layout` slot no longer receives the `onClear`, `onSetToday`, `onAccept`, `onCancel`, `onOpen`, `onClose``onDismiss`, `onChange` and `onSelectShortcut` props.
439
+
You can use the `usePickerActionsContext` or the `usePickerContext` hooks instead:
426
440
427
441
```diff
428
442
+import { usePickerActionsContext } from '@mui/x-date-pickers/hooks';
@@ -446,7 +460,7 @@ This change causes a few breaking changes:
446
460
+ setOpen(true);
447
461
+}
448
462
449
-
-props.onClose();
463
+
-const { onClose } = props;
450
464
+const { setOpen } = usePickerActionsContext();
451
465
+const onClose = event => {
452
466
+ event.preventDefault();
@@ -462,6 +476,18 @@ This change causes a few breaking changes:
@@ -471,6 +497,19 @@ This change causes a few breaking changes:
471
497
472
498
### Slot: `toolbar`
473
499
500
+
- The component passed to the `toolbar` slot no longer receives the `value` prop, instead you can use the `usePickerContext` hook:
501
+
502
+
```diff
503
+
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
504
+
505
+
// This contains a small behavior change.
506
+
// If the picker receives an invalid date,
507
+
// the old value would equal `null`.
508
+
// the new value would equal the invalid date received.
509
+
-const { value } = props;
510
+
+const { value } = usePickerContext();
511
+
```
512
+
474
513
- The component passed to the `toolbar` slot no longer receives the `disabled` and `readOnly` props, instead you can use the `usePickerContext` hook:
475
514
476
515
```diff
@@ -483,7 +522,17 @@ This change causes a few breaking changes:
483
522
+const { readOnly } = usePickerContext();
484
523
```
485
524
486
-
- The component passed to the `toolbar` slot no longer receives a `view`, `views` and `onViewChange` props, instead you can use the `usePickerContext` hook:
525
+
- The component passed to the `toolbar` slot no longer receives the `isLandscape` prop, instead you can use the `usePickerContext` hook:
526
+
527
+
```diff
528
+
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
529
+
530
+
-const { isLandscape } = props;
531
+
+const { orientation } = usePickerContext();
532
+
+const isLandscape = orientation === 'landscape';
533
+
```
534
+
535
+
- The component passed to the `toolbar` slot no longer receives the `view`, `views` and `onViewChange` props, instead you can use the `usePickerContext` hook:
487
536
488
537
```diff
489
538
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
@@ -498,9 +547,28 @@ This change causes a few breaking changes:
498
547
+const { onViewChange } = usePickerContext();
499
548
```
500
549
550
+
- The component passed to the `toolbar` slot no longer receives the `onChange` prop.
551
+
You can use the `usePickerActionsContext` or the `usePickerContext` hooks instead:
552
+
553
+
```diff
554
+
+import { usePickerActionsContext } from '@mui/x-date-pickers/hooks';
The `usePickerContext` also contain all the actions returned by `usePickerActionsContext`.
566
+
The only difference is that `usePickerActionsContext` only contains variables with stable references that won't cause a re-render of your component.
567
+
:::
568
+
501
569
### Slot: `tabs`
502
570
503
-
- The component passed to the `tabs` slot no longer receives a`view`, `views` and `onViewChange` props, instead you can use the `usePickerContext` hook:
571
+
- The component passed to the `tabs` slot no longer receives the`view`, `views` and `onViewChange` props, instead you can use the `usePickerContext` hook:
504
572
505
573
```diff
506
574
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
@@ -517,7 +585,8 @@ This change causes a few breaking changes:
517
585
518
586
### Slot: `actionBar`
519
587
520
-
- The component passed to the `actionBar` slot no longer receives the `onClear`, `onSetToday`, `onAccept` and `onCancel` props. You can use the `usePickerActionsContext` or the `usePickerContext` hooks instead:
588
+
- The component passed to the `actionBar` slot no longer receives the `onClear`, `onSetToday`, `onAccept` and `onCancel` props.
589
+
You can use the `usePickerActionsContext` or the `usePickerContext` hooks instead:
521
590
522
591
```diff
523
592
+import { usePickerActionsContext } from '@mui/x-date-pickers/hooks';
@@ -540,6 +609,44 @@ This change causes a few breaking changes:
540
609
The only difference is that `usePickerActionsContext` only contains variables with stable references that won't cause a re-render of your component.
541
610
:::
542
611
612
+
### Slot: `shortcuts`
613
+
614
+
- The component passed to the `shortcuts` slot no longer receives the `isLandscape` prop, instead you can use the `usePickerContext` hook:
615
+
616
+
```diff
617
+
+import { usePickerContext } from '@mui/x-date-pickers/hooks';
618
+
619
+
-const { isLandscape } = props;
620
+
+const { orientation } = usePickerContext();
621
+
+const isLandscape = orientation === 'landscape';
622
+
```
623
+
624
+
- The component passed to the `shortcuts` slot no longer receives the `onChange` prop.
625
+
You can use the `usePickerActionsContext` or the `usePickerContext` hooks instead:
0 commit comments