Expo Invariant Violation:元素类型无效:

时间:2018-09-07 14:21:00

标签: javascript react-native expo

我收到此错误。

不变违规:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义

不变违规:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义

这是我的代码。

import React, { Component } from 'react';
import {
  Text,
  View,
  StyleSheet,
  Image,
  TextInput,
  TouchableOpacity,
  Keyboard,
  Platform,
  Button,
  Linking,
  ScrollView
} from 'react-native';
import { Constants, Font } from 'expo';
import { CheckBox } from 'react-native-elements';
import  Etiketleme  from './Etiketleme.js';
import { FontAwesome } from '@expo/vector-icons';

// You can import from local files

// or any pure javascript modules available in npm


export default class App extends Component {


  constructor(props) {
    super(props);
    this.findItem = this.findItem.bind(this);
    this.addItem = this.addItem.bind(this);

    this.state = {
      partID: '',
      result: '',
      parts: [...],
      color: 'red',
    };
  }

  addItem() {
    this.setState({ result: '' });
    if(this.state.partID!=''){
    this.findItem();}
    Keyboard.dismiss();
  }

  findItem() {
    if (this.state.parts.indexOf(this.state.partID) >= 0) {
      this.setState({ result: 'Returnable' });
    } else {
      this.setState({ result: 'Not Returnable' });
    }
  }




  render() {
    return (
      <View
        style={{
          flex: 1,
          backgroundColor: '#c6c9dd',
          marginTop: Platform.OS == 'ios' ? 20 : 0,
        }}>
        <View
          style={{
            flex: Platform.OS == 'ios' ? 0 : 0.69,
            backgroundColor: '#363b5b',
          }}
        />
        <View
          style={{
            flex: 1.3,
            backgroundColor: '#363b5b',
            borderColor: '#efefef',
            justifyContent: 'center',
            alignItems: 'center',
          }}>
          <Text style={{ color: 'white', fontSize: 16,   fontWeight: 'bold' }}>
            {' '}
            GE Healthcare{' '}
          </Text>
        </View>
        <View
          style={{
            flex: 1.2,
            marginLeft: 15,
            marginRight: 15,
            flexDirection: 'row',
            backgroundColor: '#c6c9dd',
          }}>
          <View
            style={{
              flex: 7,
              flexDirection: 'row',
              borderRadius: 15,
              paddingLeft: 5,
              paddingRight: 5,
              justifyContent: 'center',
              backgroundColor: '#c6c9dd',
            }}>
            <View style={{ flex: 7 }}>
              <TextInput
                onSubmitEditing={event => this.addItem(event)}
                onChangeText={v => this.setState({ partID: v })}
                placeholder={'PartID'}
                style={{
                  paddingBottom: Platform.OS == 'ios' ? 2 : 8,
                  paddingLeft: 6,
                  justifyContent: 'center',
                  alignItems: 'center',
                  marginTop: 19,
                  borderBottomWidth: Platform.OS == 'ios' ? 0.5 : 0,
                }}
              />
            </View>
            <View style={{ flex: 1 }}>
              <TouchableOpacity
                style={{
                  flex: 1,
                  justifyContent: 'center',
                  alignItems: 'center',
                  backgroundColor: '#c6c9dd',
                  borderRadius: 15,
                  paddingRight: 5,
                  paddingTop: Platform.OS == 'ios' ? 15 : 5,
                }}
                onPress={this.addItem}>
                <Image
                  style={{ width: 25, height: 20 }}
                  source={require('./assets/search.png')}
                />
              </TouchableOpacity>
            </View>
          </View>
        </View>


        <View
          style={{
            flex: 1,
            backgroundColor: '#c6c9dd',
            alignItems: 'center',
            justifyContent: 'center',
            marginLeft: 15,
            marginRight: 15,
            marginTop: 3,
            borderRadius: 8,
            shadowColor: 'yellow',
          }}>
          <Text
            style={{
              color: 'black',
              fontWeight: 'bold',
              fontSize: 24,
              marginLeft: 8,
              paddingLeft: 15,
              paddingRight: 11,
            }}>
            {this.state.result}
          </Text>
        </View>

        <View style={{ flex: 8.5, marginTop:8, backgroundColor: '#c6c9dd' }}>

            <Etiketleme result={this.state.result}/>

        </View>
        <View style={{ flex: 3, backgroundColor: '#c6c9dd' }}>
          <View style={{ flex: 4, backgroundColor: '#c6c9dd' }}>


            <View
              style={{
                flex: 2,
                flexDirection: 'row',
                backgroundColor: 'red',
                borderRadius: 20,
              }}>
              <View
                style={{
                  flex: 1,
                  backgroundColor: '#c6c9dd',
                  alignItems: 'center',
                  justifyContent: 'center',
                }}>
                 <Text selectable style={{borderBottomWidth:0.7, fontWeight:"bold" }}>
                  Küçük Paket Sorumlusu
                </Text>
                <Text style={{   marginTop:5 }}>
                  Burak Dalkıran
                </Text>
                <Text selectable style={{  }}>
                  ....
                </Text>
                <Text selectable style={{   marginBottom:5 }}>
                  ....
                </Text>
              </View>
              <View
                style={{
                  flex: 1,
                  borderLeftWidth: 0.5,
                  backgroundColor: '#c6c9dd',
                  alignItems: 'center',
                  justifyContent: 'center',
                }}>
                <Text selectable style={{borderBottomWidth:0.7,   fontWeight:"bold" }}>
                  Depo İşlemleri Sorumlusu
                </Text>
                <Text style={{ marginTop:5 }}>
                  ....
                </Text>
                <Text selectable style={{ }}>
                  ...
                </Text>
                <Text selectable style={{   marginBottom:5  }}>
                  ...
                </Text>

              </View>
            </View>
          </View>
          <View
            style={{
              flex: 1.5,
              backgroundColor: '#363b5b',
              justifyContent: 'center',
            }}>
            <TouchableOpacity
              style={{
                backgroundColor: '#363b5b',
                alignItems: 'center',
                justifyContent: 'center',
              }}
              onPress={() =>
                Linking.openURL(
                  'mailto:...,...?subject=' +
                    this.state.partID +
                    '&body="' +
                    this.state.partID +
                    '" numaralı parçayı aşağıdaki detaylara istinaden UPS depoya aldırır mısınız? \n \n Alım Adresi: \n Bölüm Adı: \n İlgili Kişi: \n Telefon numarası: '+' '
                )
              }>
              <Text
                style={{
                  fontSize: 16,
                  fontWeight: 'bold',
                  color: 'white',
                }}>
                UPS GÖREVLİLERİNE MAİL GÖNDER!
              </Text>
            </TouchableOpacity>
          </View>
        </View>
      </View>
    );
  }
}

0 个答案:

没有答案