how to import lodash code example
Example 1: import lodash
import _ from "lodash"
const nums = [1, 2, 2, 3, 1, 4]
let res = _.uniq(nums)
import { uniq } from "lodash"
const nums = [1, 2, 2, 3, 1, 4]
let res = uniq(nums)
import uniq from "loadash/uniq"
const nums = [1, 2, 2, 3, 1, 4]
let res = uniq(nums)
Example 2: how to make modules structure like lodash
import { pluralize } from 'utils';
export function ShoppingCartCount({ count }) {
return (
<div>
Shopping cart has {count} {pluralize('product', count)}
</div>
);
}