Hi,
Do we have to install prop-types library when we are using create-react-app, or it already includes it?
I’m asking because, after ejecting i can’t see prop-types library neither in dependencies or devDependencies, but if i use it in the project without installing it, it works perfectly and isn’t throwing any errors that prop-types library isn’t installed.
We are recording React tutorial using create react app and knowing precise answer for this question, would be great.
Thanks!
It's included by React.
Answering your question: you may not install it, but IDE/ESLint might complain about using transitive dependencies.
@miraage
That's weird because prop-types documentation on Github, is saying nothing about it, in fact in Installation section it says npm install --save prop-types. I don't understand why would someone need to run npm install --save prop-types if it already comes with React and if it works only with React ?
Well, it could be weird. Depends on our point of view. If you ask me I find using transitive dependencies pretty weird, because I prefer strict control over dependencies tree. Meanwhile another person might not find it helpful.
@miraage agreed, thanks!
You should never rely on transitive dependencies. For example if React uses PropTypes internally (without exposing them), it could potentially remove them or change their major version, and do so in a patch release. This is safe if they’re not exposed.
Therefore you should never rely on other packages’ transitive dependencies just “being there”. Always explicitly install them (and add them to package.json) to avoid them breaking.
@gaearon understood, thanks!
i ran into an error after installing prop-types. I'm new to react and I'm using react 16 any help here?

@davidshare looks like you hit a npm bug, rm -rf node_modules, remove package-lock.json, and then run npm install again.
Most helpful comment
You should never rely on transitive dependencies. For example if React uses PropTypes internally (without exposing them), it could potentially remove them or change their major version, and do so in a patch release. This is safe if they’re not exposed.
Therefore you should never rely on other packages’ transitive dependencies just “being there”. Always explicitly install them (and add them to package.json) to avoid them breaking.