Norfeldt
Norfeldt

Reputation: 9678

React Native importing only what is needed

Say I have the following:

import validator from 'validator'

and in my code do:

validator.isEmail(txt)

Would that import the entire validator and increase the overall package size?


if, how do I avoid this?

Upvotes: 1

Views: 78

Answers (1)

agent3bood
agent3bood

Reputation: 1354

Your statement will import the whole validator. What are you looking for is this

    import { isEmail } from ‘validator’

isEmail should be e exported in the source file.

Upvotes: 3

Related Questions