Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What I should do if another dependency use React.PropTypes #11661

Closed
theGABS opened this issue Nov 25, 2017 · 3 comments
Closed

What I should do if another dependency use React.PropTypes #11661

theGABS opened this issue Nov 25, 2017 · 3 comments

Comments

@theGABS
Copy link

theGABS commented Nov 25, 2017

I use "react": "16.0.0-beta.5".

Some another package use React.PropTypes - I cannot update another package. What should I Do?

I search some polyfill. I try to write my own, but it doesn't work.

import * as allReact from 'react';
import PropTypes from 'prop-types';

allReact.PropTypes = PropTypes
@gaearon
Copy link
Collaborator

gaearon commented Nov 25, 2017

As a temporary escape hatch you can create patchReact.js with

const React = require('react');
const PropTypes = require('prop-types');

React.PropTypes = PropTypes;

and then put

import './patchReact';

as the very first import in your app before any other imports. Then it will work.

But really, you should file an issue with the package that still uses React.PropTypes or fork it. There is an automated conversion script you can use for that.

PS Don't use 16 betas :-) A stable version has been out for a few months now.

@gaearon gaearon closed this as completed Nov 25, 2017
@theGABS
Copy link
Author

theGABS commented Nov 25, 2017

I don't sure.
But looks like it doesn't work.

I got:
undefined is not an object
evaluating _react2.PropTypes.object

@gaearon
Copy link
Collaborator

gaearon commented Nov 25, 2017

This is not enough information to help you, sorry. We can't guess what went wrong without a full reproducing example.

Also, this is a bug tracker. Please refer to community resources for support: https://reactjs.org/community/support.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants