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

undefined is not an object (evaluating 'react3.default.PropTypes.bool) #39

Open
uguryiilmz opened this issue Apr 1, 2018 · 7 comments

Comments

@uguryiilmz
Copy link

After I downloaded this package and tried to use it I am geting an error. My code is in the below

import Image from 'react-native-transformable-image'

 ```
return (
            <Image source={{uri: 'http'}} style={s.backgroundImage} />
        );
@zk6859
Copy link

zk6859 commented Apr 9, 2018

me too

@chrismcleod
Copy link

@uguryiilmz @zk6859

This is because PropTypes used to be defined in the React module, but has since been extracted to a separate module prop-types

Try this:
yarn add prop-types

then in a file that is required before all others:

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

Remeber that import is hoisted, so in your bootstrap file, best to use all requires and no imports. For example this fixed this issue for me:

in ~/Project/index.js

// require React first
const React = require('react');

// Augment React module with PropTypes
React.PropTypes = require('prop-types');

// Now require our project files.  At this point, all references to React will have React.PropTypes defined
const { AppRegistry } = require('react-native');
const { App } = require('./App');
AppRegistry.registerComponent("Project", () => App);

@xstable
Copy link

xstable commented Jun 1, 2018

@chrismcleod It dosn't work this way for me.

I've done this:

import React from 'react';
import PropTypes from 'prop-types';
...
import {Image} from 'react-native-transformable-image';
...
render....:
<Image
                                    style={styles.detailImageAnfahrt}
                                    source={{uri: data.picture_url}}

                                />

Still got the same error. Any Idea?

BTW: The fork of dflourusso works quite well: https://github.com/dflourusso/react-native-transformable-image
Install it via: yarn add https://github.com/dflourusso/react-native-transformable-image.git, and all just work fine.

@zk6859
Copy link

zk6859 commented Jun 4, 2018

@chrismcleod Thank you,I got it.

@MihailShab
Copy link

MihailShab commented Jun 28, 2018

@xstable you need to add "import PropTypes from 'prop-types';" in /node_modules/react-native-view-transformer/library/transform/ViewTransformer.js and change React.PropTypes to PropTypes

@iffj
Copy link

iffj commented Sep 15, 2018

@chrismcleod It dosn't work this way for me.

I've done this:

import React from 'react';
import PropTypes from 'prop-types';
...
import {Image} from 'react-native-transformable-image';
...
render....:
<Image
                                    style={styles.detailImageAnfahrt}
                                    source={{uri: data.picture_url}}

                                />

Still got the same error. Any Idea?

BTW: The fork of dflourusso works quite well: https://github.com/dflourusso/react-native-transformable-image
Install it via: yarn add https://github.com/dflourusso/react-native-transformable-image.git, and all just work fine.

the fork also works for me

@chaosuperDK
Copy link

@chrismcleod It dosn't work this way for me.

I've done this:

import React from 'react';
import PropTypes from 'prop-types';
...
import {Image} from 'react-native-transformable-image';
...
render....:
<Image
                                    style={styles.detailImageAnfahrt}
                                    source={{uri: data.picture_url}}

                                />

Still got the same error. Any Idea?

BTW: The fork of dflourusso works quite well: https://github.com/dflourusso/react-native-transformable-image
Install it via: yarn add https://github.com/dflourusso/react-native-transformable-image.git, and all just work fine.

Just got the same issue and read the source code found out it imports another lib as below :
import ViewTransformer from 'react-native-view-transformer';
So you have to find this lib and refactor all React.PropTypes to PropTypes. And don't forget to import PropTypes from prop-types.
Hope this will help you

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

7 participants