question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we have to install prop-types library when we are using create-react-app, or it already includes it?

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
gaearoncommented, Feb 6, 2018

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.

1reaction
Timercommented, Feb 26, 2018

@davidshare looks like you hit a npm bug, rm -rf node_modules, remove package-lock.json, and then run npm install again.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found