react-native-transformable-image icon indicating copy to clipboard operation
react-native-transformable-image copied to clipboard

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

Open uguryiilmz opened this issue 6 years ago • 7 comments

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} />
        );

uguryiilmz avatar Apr 01 '18 03:04 uguryiilmz

me too

zk6859 avatar Apr 09 '18 06:04 zk6859

@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);

chrismcleod avatar Apr 12 '18 19:04 chrismcleod

@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.

xstable avatar Jun 01 '18 16:06 xstable

@chrismcleod Thank you,I got it.

zk6859 avatar Jun 04 '18 09:06 zk6859

@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

MihailShab avatar Jun 28 '18 13:06 MihailShab

@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

iffj avatar Sep 15 '18 03:09 iffj

@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

chaosuperDK avatar Sep 09 '19 03:09 chaosuperDK