错误:预期的字符串或类/函数但发现:object react-native

时间:2016-06-02 10:19:11

标签: javascript android debugging react-native

我正在尝试实现react-native侧视图https://github.com/react-native-fellowship/react-native-side-menu 现在发生的事情是,当我尝试添加菜单组件时,它显示错误而没有任何关于错误是什么的指示我认为它是基于javascript但仍然无法确定确切的原因。任何帮助将不胜感激。

这是Menu.js

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */

import React, { Component } from 'react';
import {
  Dimensions,
 StyleSheet,
 ScrollView,
 View,
 Image,
 Text,
} from 'react-native';

const window = Dimensions.get('window');


class Menu extends Component {
  static propTypes = {
    onItemSelected: React.PropTypes.func.isRequired,
  };

  render() {
    return (
      <ScrollView scrollsToTop={false} style={styles.menu}>
        <View style={styles.avatarContainer}>
          <Text style={styles.name}>Your name</Text>
        </View>

        <Text
          onPress={() => this.props.onItemSelected('About')}
          style={styles.item}>
          About
        </Text>

        <Text
          onPress={() => this.props.onItemSelected('Contacts')}
          style={styles.item}>
          Contacts
        </Text>
      </ScrollView>
    );
  }
};

const styles = StyleSheet.create({
  menu: {
    flex: 1,
    width: window.width,
    height: window.height,
    backgroundColor: 'gray',
    padding: 20,
  },
  avatarContainer: {
    marginBottom: 20,
    marginTop: 20,
  },
  avatar: {
    width: 48,
    height: 48,
    borderRadius: 24,
    flex: 1,
  },
  name: {
    position: 'absolute',
    left: 70,
    top: 20,
  },
  item: {
    fontSize: 14,
    fontWeight: '300',
    paddingTop: 5,
  },
});

module.export = Menu;

这是使用此组件的代码,现在它提供错误,如图所示

const SideMenu = require('react-native-side-menu');
// var Menu = require('./Menu').default;
class Application extends Component {


  onMenuItemSelected = (item) => {
    this.setState({
      isOpen: false,
      selectedItem: item,
    });
  }

  render() {
    // const menu = <Menu onItemSelected={this.onMenuItemSelected} />;
    return (
      <SideMenu menu={<Menu />}>

The Error code which is recieved

0 个答案:

没有答案