2016-11-01 14 views
0

現在、React Native認証の基本チュートリアルに従っています。ReactNative.Componentエラーにアクセスしようとしました

enter image description here

が、私はエラーを理解し、私は間違ってやっているものを見ることができない:私はプロジェクトを起動すると、次のエラーが発生します。特に、私はエラーが消えてプロジェクトがコンパイルされるまで私の意見をコメントアウトしました。ここに加害者がいる。なぜこのようなエラーが現れるのでしょうか? tcomb-form-nativeからの文書によると

import React, { Component } from 'react'; 

import { 
    ScrollView, 
    StyleSheet, 
    TouchableHighlight, 
    Text 
} from 'react-native'; 

const t = require('tcomb-form-native'); 

const Form = t.form.Form 

const newUser = t.struct({ 
    email: t.String, 
    password: t.String 
}) 

const options = { 
    fields: { 
    email: { 
     autoCapitalize: 'none', 
     autoCorrect: false 
    }, 
    password: { 
     autoCapitalize: 'none', 
     password: true, 
     autoCorrect: false 
    } 
    } 
} 

class RegisterView extends Component { 

    constructor(props) { 
    super(props) 
    this.state = { 
     value: { 
     email: '', 
     password: '' 
     } 
    } 
    } 

    componentWillUnmount() { 
    this.setState = { 
     value: { 
     email: '', 
     password: null 
     } 
    } 
    } 

    _onChange = (value) => { 
    this.setState({ 
     value 
    }) 
    } 

    _handleAdd =() => { 
    const value = this.refs.form.getValue(); 
    // If the form is valid... 
    if (value) { 
     const data = { 
     email: value.email, 
     password: value.password, 
     } 
     // Serialize and post the data 
     const json = JSON.stringify(data); 
     fetch('http://localhost:3000/users/register', { 
     method: 'POST', 
     headers: { 
      'Content-Type': 'application/json', 
      Accept: 'application/json' 
     }, 
     body: json 
     }) 
     .then((response) => response.json()) 
     .then(() => { 
     alert('Success! You may now log in.'); 
     // Redirect to home screen 
     this.props.navigator.pop(); 
     }) 
     .catch((error) => { 
     alert('There was an error creating your account.'); 
     }) 
     .done() 
    } else { 
     // Form validation error 
     alert('Please fix the errors listed and try again.') 
    } 
    } 

    render() { 
    return (
     <ScrollView style={styles.container}> 
     <Form 
      ref='form' 
      type={newUser} 
      options={options} 
      value={this.state.value} 
      onChange={this._onChange} 
     /> 
     <TouchableHighlight onPress={this._handleAdd}> 
      <Text style={[styles.button, styles.greenButton]}>Create account</Text> 
     </TouchableHighlight> 
     </ScrollView> 
    ) 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
    padding: 20, 
    flex: 1, 
    flexDirection: 'column' 
    }, 
    button: { 
    borderRadius: 4, 
    padding: 20, 
    textAlign: 'center', 
    marginBottom: 20, 
    color: '#fff' 
    }, 
    greenButton: { 
    backgroundColor: '#4CD964' 
    }, 
    centering: { 
    alignItems: 'center', 
    justifyContent: 'center' 
    } 
}) 

module.exports = RegisterView 
+0

どのバージョンのtcomb-form-nativeを使用していますか? – Jickson

+0

おそらく、@Jicksonが言ったように、おそらくtcomb-from-native didntアップデートです。 –

+0

"tcomb-form-native": "^ 0.4.4" – MadPhysicist

答えて

0

tcomb-form-native ^0.5: react-native >= 0.25.0 tcomb-form-native ^0.4: react-native >= 0.20.0 tcomb-form-native ^0.3: react-native < 0.13.0

react-native --versionnpm install [email protected]が私のために問題を解決し実行している、したがって

react-native-cli: 1.0.0 react-native: 0.36.0

ました。

関連する問題