简体   繁体   中英

Why is it not ideal to import react-bootstrap using destructuring

The documentation page suggests to only import the components needed. There are 2 examples given here https://react-bootstrap.netlify.com/getting-started/introduction#importing :

import Button from 'react-bootstrap/lib/Button';

// or less ideally
import { Button } from 'react-bootstrap';

What makes the 2nd method 'less ideal'?

In the first case you are only importing the code for that particular component.

In the second case you are importing the whole library and inserting only a particular component into the current scope.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM