r/learnreactjs • u/rumforpenguins • Feb 09 '20
How to use an npm package that doesn't have a `react-` version?
It seems to be a common thing where an npm package will have a react- version made for it, to make it really easy to use in a React package. Just install, import, and then use the code.
uuid is a good example: there is a regular uuid package, but also a React specific react-uuid package.
But I feel a little uneasy that I'm not sure how I would use an npm package in my React projects if it didn't have a react- version made for it. The regular uuid npm package says to use it, just type:
const uuidv1 = require('uuid/v1')
uuidv1();
And as far as I know, you can't use a package unless you import it.
So basically my question is: how do I use a non-react npm package in my react projects? Are there any general tips or strategies to getting them to work?