fixt / react-native-page-swiper

91 stars 47 forks source link

undefined is not an object #24

Open MinhMinh8722 opened 6 years ago

MinhMinh8722 commented 6 years ago

I copied your example into App.js and had an error. screen shot 2017-11-15 at 09 39 19

Please help me!!!

And this is my code:

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import Swiper from 'react-native-page-swiper'

export default class App extends Component<{}> {
  render() {
    return (
        <Swiper style={styles.wrapper}>
          <View style={styles.slide1}>
            <Text style={styles.text}>Hello Swiper</Text>
          </View>

          <View style={styles.slide2}>
            <Text style={styles.text}>Beautiful</Text>
          </View>

          <View style={styles.slide3}>
            <Text style={styles.text}>And simple</Text>
          </View>
        </Swiper>
    );
  }
}

var styles = StyleSheet.create({
    wrapper: {
    },
    slide1: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#9DD6EB',
    },
    slide2: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#97CAE5',
    },
    slide3: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#92BBD9',
    },
    text: {
        color: '#fff',
        fontSize: 30,
        fontWeight: 'bold',
    }
});
twavis commented 6 years ago

The version of the code that is posted on npm is dated and doesn't work with later versions of RN. You can install the latest committed code that fixes the issue with npm i github:fixt/react-native-page-swiper#b19964571c7b690c66362d92c1239054fc0546db --save

QuestInfosense commented 5 years ago

Please import the PropTypes module. it has been moved to an external package so in order to use PropTypes you'll need to import the package.

sudo npm install prop-types --save And then reference the package like this

import PropTypes from 'prop-types'; Note : Please remove the outdated package usage. While adding dependencies please make sure that package version is support by the react latest version.