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.

Instead of removing propTypes, replace with empty object

See original GitHub issue

Removing propTypes entirely is causing issues with third party dependencies that need them to be defined. This was causing issues when using react-native-web.

It was brought up that replacing propTypes with an empty object would have the effects of not needing those definitions, while allowing libraries to reference undefined properties on propTypes and prevent cannot read [name] of undefined errors.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
virgofxcommented, Apr 12, 2017

The purpose of the plugin is to remove prop types. That’s what it should do. If a 3rd party library is using the plugin but expecting prop types … then that’s their issue.

Using proper babel environments one can define the necessary requirements (dist should use this plugin, but development, normal imports should not). There are numerous examples of vendors using this properly allowing prop types in development, internal builds, but excluding for dist versions. Please see those.

[close issue please]

1reaction
ndbroadbentcommented, Apr 24, 2017

Here’s my attempt at replacing propTypes with an object. I’ve been testing it with my react-native-web app, and it seems to work perfectly.

I’m still finding my way around the Babel AST, so the code is not very good. But it works well for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way in React to change a prop type to avoid ...
I'm wondering if there's a way to change a prop type if the one that is being passed isn't of the type expected....
Read more >
prop-types
Runtime type checking for React props and similar objects. ... To load a specific version of prop-types replace 15.6.0 with the version ...
Read more >
Typescript & React: Manipulating Prop Types | by Ross Bulat
Let's explore how to do this using the Exclude and Pick helper types in Typescript alongside extends and keyof type operators. Removing unneeded...
Read more >
Learn React PropTypes In 13 Minutes - YouTube
Learn React Today Course: https://courses.webdevsimplified.com/learn-react-todayWith React it is very easy to accidentally pass incorrect ...
Read more >
How To Style React Components
Delete the line import logo from './logo.svg'; . Then replace everything in the return statement to return a set of empty tags: <></>...
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