Correct way to import lodash

I had a pull request feedback below, just wondering which way is the correct way to import lodash?

You’d better do import has from ‘lodash/has’.. For the earlier version
of lodash (v3) which by itself is pretty heavy, we should only import
a specidic module/function rather than importing the whole lodash
library. Not sure about the newer version (v4).

import has from 'lodash/has';

vs

import { has } from 'lodash';

Thanks

10 Answers
10

Leave a Comment