react-native-slideshow
react-native-slideshow copied to clipboard
undefined is not an object (evaluating '_react2.PropTypes.arrayOff')
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
I have the same issue
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';
Thank you @IElgohary
@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 ?
@IElgohary What do you mean? I added the npm install and imported proptypes but i still get an error.
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;
@hesusdios import your prop-type at node_modules/react-native-slideshow/Slideshow.js
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';
@adityajhordan Sorry for the late reply. Personally, I just took the code from Slideshow.js and added it to my code.
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.
haqihaqi, could you patch your code as IElgohary suggested?
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
I solved the issue
@Muedgar how u solved the issue ?
i have same issue here ...
@haqiqiw Can you push this fix to npm?
Hi everybody. I have the same issue, i tried solutions up here and still have the error how do i fix this, please help
it can be fixed by removing Proptypes which import from react, then import Proptypes from prop-types in Slideshow.js (react-native-slideshow).
@Muedgar How did you solve that?
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';
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?