undefined不是对象(评估'_react3.default.PropTypes.object')

时间:2017-12-22 12:14:31

标签: javascript android reactjs react-native

我正在学习React-native因为这个案例我想为Android创建导航,实际上,我遇到了错误

错误:React native Undefined不是对象(评估'_react3.default.PropTypes.object')

react-native:0.51

import React, { Component } from 'react';
import {StyleSheet,Text,View,TextInput,KeyboardAvoidingView,TouchableOpacity,
  AsyncStorage} from 'react-native';

 import AtoZList from 'react-native-atoz-list';
import randomcolor from 'randomcolor';
import _ from 'lodash';
let names = require('./names');
names = _.groupBy(require('./names'), (name) => name[0].toUpperCase());

export default class startActivity extends React.Component {
  constructor(props, context) {
         super(props, context);

         this._renderCell = this._renderCell.bind(this);
         this._renderHeader = this._renderHeader.bind(this);
     }

     _renderHeader(data) {
             return (
                 <View style={{ height: 35, justifyContent: 'center', backgroundColor: '#eee', paddingLeft: 10 }}>
                     <Text>{data.sectionId}</Text>
                 </View>
             )
         }


         _renderCell(data) {
             return (
                 <View style={styles.cell}>
                     <View style={[styles.placeholderCircle, { backgroundColor: randomcolor() }]} />
                     <Text style={styles.name}>
                         {data} {data.split('').reverse().join('')}
                     </Text>
                 </View>
             );
         }


  render() {
    const title = "let's go";
    return (
      <AtoZList
                 sectionHeaderHeight={35}
                 cellHeight={95}
                 data={names}
                 renderCell={this._renderCell}
                 renderSection={this._renderHeader}
                 />
    );
  }
}

1 个答案:

答案 0 :(得分:-1)

试试这个:

var self
export default class startActivity extends React.Component {
  constructor(props, context) {
         super(props, context);
         self = this

   }

     _renderHeader(data) {
             return (
                 <View style={{ height: 35, justifyContent: 'center', backgroundColor: '#eee', paddingLeft: 10 }}>
                     <Text>{data.sectionId}</Text>
                 </View>
             )
         }


         _renderCell(data) {
             return (
                 <View style={styles.cell}>
                     <View style={[styles.placeholderCircle, { backgroundColor: randomcolor() }]} />
                     <Text style={styles.name}>
                         {data} {data.split('').reverse().join('')}
                     </Text>
                 </View>
             );
         }


  render() {
    const title = "let's go";
    return (
      <AtoZList
                 sectionHeaderHeight={35}
                 cellHeight={95}
                 data={names}
                 renderCell={self._renderCell}
                 renderSection={self._renderHeader}
                 />
    );
  }
}