Do we have to install prop-types library when we are using create-react-app, or it already includes it?
See original GitHub issueHi,
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!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Accessing PropTypes via the main React package is deprecated
PropTypes is deprecated and has moved to another library. You should use npm install prop-types and use PropTypes from there. The code at...
Read more >How to Use PropTypes in React - freeCodeCamp
Before the release of React 15.5.0, PropTypes were available in the React package, but now we have to add the prop-types library in...
Read more >Typechecking with PropTypes In React - Upmostly
PropTypes is a library that provides certain utilities for documenting the intended types of properties that are being passed down to components.
Read more >Using propType declarations to document your React ...
When we write React components, we use the prop-types module to do basic ... npm install -g create-react-app // if you've not got...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@davidshare looks like you hit a npm bug,
rm -rf node_modules
, removepackage-lock.json
, and then runnpm install
again.