Skip to content

Commit

Permalink
[docs] New page for the pickers migration from the lab (#4327)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle authored Apr 4, 2022
1 parent b4c16bd commit 2962d6a
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
86 changes: 86 additions & 0 deletions docs/data/date-pickers/migration-lab/migration-lab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: MUI X - Migration from the lab
---

# MUI X - Migration from the lab

<p class="description">MUI date and time pickers are now available on X!</p>

## Introduction

This is a reference for migrating your site's pickers from `@mui/lab` to `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`.
This migration only concerns packages and should do not affect the behavior of the components in your app.

We explored the reasons of this migration in a [blog post](https://mui.com/blog/lab-date-pickers-to-mui-x/)

## License

Most of our components remains MIT and are accessible for free in `@mui/x-date-pickers`.

The range-picker components: `DateRangePicker`, `DateRangePickerDay`, `DesktopDateRangePicker`, `MobileDateRangePicker` and `StaticDateRangePicker`
were marked as "intended for MUI X Pro" in our documentation and are now part of MUI X Pro.

If you are using one of these components, you will have to take a Pro license in order to migrate to `@mui/x-date-pickers-pro` (see the [Pricing](https://mui.com/pricing/) page for more information).

**Note**: If you already have a license for `@mui/x-data-grid-pro`, you can use the same one for `@mui/x-date-pickers-pro` with no additional fee!

## Migration steps

### 1. Install MUI X packages

**Note:** `@mui/x-date-pickers-pro` re-exports everything from `@mui/x-date-pickers`. You don't have to install both when using the Pro Plan.

#### Community Plan

```sh
// with npm
npm install @mui/x-date-pickers

// with yarn
yarn add @mui/x-date-pickers
```

#### Pro Plan

```sh
// with npm
npm install @mui/x-date-pickers-pro @mui/x-license-pro

// with yarn
yarn add @mui/x-date-pickers-pro @mui/x-license-pro
```

When you purchase a commercial license, you'll receive a license key by email.
You must set the license key before rendering the first component.

```jsx
import { LicenseInfo } from '@mui/x-license-pro';

LicenseInfo.setLicenseKey(
'x0jTPl0USVkVZV0SsMjM1kDNyADM5cjM2ETPZJVSQhVRsIDN0YTM6IVREJ1T0b9586ef25c9853decfa7709eee27a1e',
);
```

More information [here](/x/advanced-components/#license-key-installation)

### 2. Run the code mod

We have prepared a codemod to help you migrate your codebase

```sh
npx @mui/codemod v5.0.0/date-pickers-moved-to-x <path>
```

Which will transform the imports like this:

```diff
- import DatePicker from '@mui/lab/DatePicker';
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';

- import DateRangePicker from '@mui/lab/DateRangePicker';
+ import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker';

- import { DatePicker, DateRangePicker } from '@mui/lab';
+ import { DatePicker } from '@mui/x-date-pickers'; // DatePicker is also available in `@mui/x-date-pickers-pro`
+ import { DateRangePicker } from '@mui/x-date-pickers-pro';
```
3 changes: 2 additions & 1 deletion docs/data/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pages = [
{ pathname: '/x/react-data-grid', title: 'Overview' },
{ pathname: '/x/react-data-grid/demo' },
{ pathname: '/x/react-data-grid/getting-started' },
{ pathname: '/x/react-data-grid/migration-v4', title: 'Migration From v4' },
{ pathname: '/x/react-data-grid/migration-v4', title: 'Migration from v4' },
{ pathname: '/x/react-data-grid/layout' },
{ pathname: '/x/react-data-grid/columns' },
{ pathname: '/x/react-data-grid/rows' },
Expand Down Expand Up @@ -62,6 +62,7 @@ const pages = [
icon: 'TableViewIcon',
children: [
{ pathname: '/x/react-date-pickers/getting-started' },
{ pathname: '/x/react-date-pickers/migration-lab', title: 'Migration from the lab' },
{ pathname: '/x/react-date-pickers/date-picker' },
{
pathname: '/x/react-date-pickers/date-range-picker',
Expand Down
11 changes: 11 additions & 0 deletions docs/pages/x/react-date-pickers/migration-lab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import {
demos,
docs,
demoComponents,
} from 'docsx/data/date-pickers/migration-lab/migration-lab.md?@mui/markdown';

export default function Page() {
return <MarkdownDocs demos={demos} docs={docs} demoComponents={demoComponents} />;
}

0 comments on commit 2962d6a

Please sign in to comment.