Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] New page for the pickers migration from the lab #4327

Merged
merged 9 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' },
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved
{ 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} />;
}