Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

undefined is not an object (evaluating '_react2.PropTypes.arrayOff') #4

Open
thanhppm opened this issue Dec 1, 2017 · 20 comments
Open

Comments

@thanhppm
Copy link

thanhppm commented Dec 1, 2017

Hello, when i have devlopment with react-native-slideshow, i have one off issue be like
"undefined is not an object (evaluating '_react2.PropTypes.arrayOff')".
this is errors display http://prntscr.com/hhm4u1
Could you help me? Thanks

@bec-smith
Copy link

I have the same issue

@IElgohary
Copy link

IElgohary commented Dec 4, 2017

It's because in later versions of react, prop-types is an independent npm module.
just run
npm install --save prop-types
and in Slideshow.js, remove PropTypes from the imports from React and add this line:
import PropTypes from 'prop-types';

@thanhppm
Copy link
Author

thanhppm commented Dec 5, 2017

Thank you @IElgohary

@adityajhordan
Copy link

@IElgohary yup, it solved, but every time I did rm -rf node_modules then npm install, we have to write PropTypes at SlideShow.js again, is there any solution for that ?

@ReangeloJ
Copy link

@IElgohary What do you mean? I added the npm install and imported proptypes but i still get an error.

@ReangeloJ
Copy link

import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import Slideshow from 'react-native-slideshow';
import PropTypes from 'prop-types';

class SlideshowGallery extends React.Component {
constructor(props) {
super(props);

    this.state = {
        position: 1,
        interval: null,
        dataSource: [
            {
                title: 'Title 1',
                caption: 'Caption 1',
                url: 'http://placeimg.com/640/480/any',
            }, {
                title: 'Title 2',
                caption: 'Caption 2',
                url: 'http://placeimg.com/640/480/any',
            }, {
                title: 'Title 3',
                caption: 'Caption 3',
                url: 'http://placeimg.com/640/480/any',
            },
        ],
    };
}

componentWillMount() {
    this.setState({
        interval: setInterval(() => {
            this.setState({
                position: this.state.position === this.state.dataSource.length ? 0 : this.state.position + 1
            });
        }, 2000)
    });
}

componentWillUnmount() {
    clearInterval(this.state.interval);
}

render() {
    return (
        <Slideshow
            dataSource={this.state.dataSource}
            position={this.state.position}
            onPositionChanged={position => this.setState({ position })} />
    );
}

}

export default SlideshowGallery;

@wmars91
Copy link

wmars91 commented Jan 18, 2018

@hesusdios import your prop-type at node_modules/react-native-slideshow/Slideshow.js

@ahmedcs2600
Copy link

It works 👍
npm install --save prop-types
and in Slideshow.js, remove PropTypes from the imports from React and add this line:
import PropTypes from 'prop-types';

@IElgohary
Copy link

@adityajhordan Sorry for the late reply.
Personally, I just took the code from Slideshow.js and added it to my code.

@ga-reth
Copy link

ga-reth commented Apr 2, 2018

Hi, I have used the above solutions:
+npm install --save prop-types
+Slideshow.js: import PropTypes from 'prop-types';

However, I'm still receiving the error.

@marcmoo
Copy link

marcmoo commented Jun 1, 2018

haqihaqi, could you patch your code as IElgohary suggested?

@Muedgar
Copy link

Muedgar commented Jun 27, 2018

I am using react-native-slideshow but I get this error:
Cannot read property 'arrayOf' of undefined.

I did as some answer suggested:
// install prop-types module
// then import it in the codebase
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Slideshow from 'react-native-slideshow';

export default class App extends Component {

render() {
return (
<Slideshow
dataSource={[
{ url:'http://placeimg.com/640/480/any' },
{ url:'http://placeimg.com/640/480/any' },
{ url:'http://placeimg.com/640/480/any' }
]}/>
);
}
}

But I am still getting the same error:
Help me please

@Muedgar
Copy link

Muedgar commented Jun 27, 2018

I solved the issue

@robiadiprawira
Copy link

@Muedgar how u solved the issue ?

i have same issue here ...

@mercxry
Copy link

mercxry commented Jul 11, 2018

@haqiqiw Can you push this fix to npm?

@SIR-MHD
Copy link

SIR-MHD commented Jul 18, 2018

Hi everybody.
I have the same issue, i tried solutions up here and still have the error
how do i fix this, please help

@suresssh
Copy link

it can be fixed by removing Proptypes which import from react, then import Proptypes from prop-types in Slideshow.js (react-native-slideshow).

@syyam
Copy link

syyam commented Jul 26, 2018

@Muedgar How did you solve that?

@Uzairrrr
Copy link

npm install --save prop-types
and in Slideshow.js,(node module/react-native-slideshow/slideshow.js) remove PropTypes from the imports from React and add this line:
import PropTypes from 'prop-types';

@salmansayyidulhaq
Copy link

import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import Slideshow from 'react-native-slideshow';
import PropTypes from 'prop-types';

class SlideshowGallery extends React.Component {
constructor(props) {
super(props);

    this.state = {
        position: 1,
        interval: null,
        dataSource: [
            {
                title: 'Title 1',
                caption: 'Caption 1',
                url: 'http://placeimg.com/640/480/any',
            }, {
                title: 'Title 2',
                caption: 'Caption 2',
                url: 'http://placeimg.com/640/480/any',
            }, {
                title: 'Title 3',
                caption: 'Caption 3',
                url: 'http://placeimg.com/640/480/any',
            },
        ],
    };
}

componentWillMount() {
    this.setState({
        interval: setInterval(() => {
            this.setState({
                position: this.state.position === this.state.dataSource.length ? 0 : this.state.position + 1
            });
        }, 2000)
    });
}

componentWillUnmount() {
    clearInterval(this.state.interval);
}

render() {
    return (
        <Slideshow
            dataSource={this.state.dataSource}
            position={this.state.position}
            onPositionChanged={position => this.setState({ position })} />
    );
}

}

export default SlideshowGallery;

can it be from firebase?

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

No branches or pull requests