Unverified Commit a7b0e8a7 authored by Ty Mick's avatar Ty Mick Committed by GitHub

Fix DatePicker Day.js bug in Ant Design example (#12580)

* Fix DatePicker Day.js bug in Ant Design example

* Lint fix
Co-authored-by: 's avatarLuis Alvarez <luis@vercel.com>
parent d37891a9
/**
* This example previously used antd-dayjs-webpack-plugin
* (https://github.com/ant-design/antd-dayjs-webpack-plugin) to attempt to
* replace Moment.js with Day.js, but it would crash the page when the user
* clicked on the DatePicker. Using this custom component (following Ant Design
* guidelines at https://ant.design/docs/react/replace-moment) instead of the
* webpack plugin fixes that bug.
*/
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs'
import generatePicker from 'antd/es/date-picker/generatePicker'
const DatePicker = generatePicker(dayjsGenerateConfig)
export default DatePicker
......@@ -33,15 +33,8 @@ const compose = plugins => ({
})
const withBundleAnalyzer = require('@next/bundle-analyzer')
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin')
module.exports = compose([
{
webpack(config, { buildId, dev, isServer, defaultLoaders, webpack }) {
config.plugins.push(new AntdDayjsWebpackPlugin())
return config
},
},
[
withBundleAnalyzer,
{
......
......@@ -11,7 +11,6 @@
"@ant-design/icons": "^4.0.6",
"@next/bundle-analyzer": "^9.1.4",
"antd": "4.1.2",
"antd-dayjs-webpack-plugin": "1.0.0",
"babel-plugin-import": "1.13.0",
"cross-env": "^7.0.2",
"dayjs": "1.8.24",
......
import React from 'react'
import {
Form,
Select,
InputNumber,
DatePicker,
Switch,
Slider,
Button,
} from 'antd'
import { Form, Select, InputNumber, Switch, Slider, Button } from 'antd'
// Custom DatePicker that uses Day.js instead of Moment.js
import DatePicker from '../components/DatePicker'
import { SmileFilled } from '@ant-design/icons'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment