react-native-slideshow icon indicating copy to clipboard operation
react-native-slideshow copied to clipboard

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

Open thanhppm opened this issue 7 years ago • 20 comments

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

thanhppm avatar Dec 01 '17 08:12 thanhppm

I have the same issue

bec-smith avatar Dec 03 '17 07:12 bec-smith

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';

IElgohary avatar Dec 04 '17 18:12 IElgohary

Thank you @IElgohary

thanhppm avatar Dec 05 '17 07:12 thanhppm

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

adityajhordan avatar Jan 09 '18 09:01 adityajhordan

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

ReangeloJ avatar Jan 16 '18 00:01 ReangeloJ

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;

ReangeloJ avatar Jan 16 '18 00:01 ReangeloJ

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

wmars91 avatar Jan 18 '18 02:01 wmars91

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';

ahmedcs2600 avatar Jan 28 '18 16:01 ahmedcs2600

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

IElgohary avatar Feb 27 '18 18:02 IElgohary

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.

ga-reth avatar Apr 02 '18 12:04 ga-reth

haqihaqi, could you patch your code as IElgohary suggested?

marcmoo avatar Jun 01 '18 18:06 marcmoo

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 avatar Jun 27 '18 17:06 Muedgar

I solved the issue

Muedgar avatar Jun 27 '18 17:06 Muedgar

@Muedgar how u solved the issue ?

i have same issue here ...

robiadiprawira avatar Jul 03 '18 03:07 robiadiprawira

@haqiqiw Can you push this fix to npm?

mercxry avatar Jul 11 '18 15:07 mercxry

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

SIR-MHD avatar Jul 18 '18 09:07 SIR-MHD

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

suresssh avatar Jul 23 '18 07:07 suresssh

@Muedgar How did you solve that?

syyam avatar Jul 26 '18 05:07 syyam

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';

Uzairrrr avatar Sep 25 '18 09:09 Uzairrrr

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?

salmansayyidulhaq avatar Oct 09 '18 06:10 salmansayyidulhaq