How to use only DatePicker from antd

Viewed 917

antd is a huge library. when I do

"npm i antd"  it downloads the whole library.

I just want to use DatePicker from antd library.

Please let me know if there is a way to do it.

I don't want to use other date picker libraries as antd is full-filling my conditions

1 Answers

when you do npm install antd it will add all to node_modules

but when you use in your code you do

import DatePicker from 'antd/date-picker'; it will only bundle the code of date-picker and it's dependencies. you will also need to import the css manually.

you will obviously need to setup webpack so it will do treeshaking and strip other components out.

if you use babel-plugin-import with antd then it will do that automatically for you.

Ultimately you can use their raw unstyled date picker(which is the one used antd under the hood" https://github.com/react-component/picker

Related