Получение ошибки для навигации в сегменте - response-native - PullRequest
0 голосов
/ 29 июня 2018

Я новичок и создаю первое приложение на реагирующем языке. Я сделал это, но застрял в одном месте. Я просто добавил сегмент в заголовке и скрыл / показал страницу входа / регистрации в базе кликов сегмента, но проблема связана с навигацией, у меня есть кнопка на странице входа, но это не работает и выдает ошибку. Вот мой сегмент страницы Код

import React, { Component } from 'react'; import { Platform, StyleSheet, Text, ScrollView } from 'react-native'; 
import { Container, Header, Left,Button,Icon,Body,Title, Segment, View, Content } from 'native-base';
import Login from './login'; import Signup from './signup';

const forgot = (props) => ( 
  <View style={{
 flex:1,
 flexDirection:'row',
 justifyContent:'center',
 alignItems:'center'
 }} > 
   <Text style={{
   fontSize:17,justifyContent:'center'
   }}> 
   Register a new account 
   <Text/>
 <View>
)
export default class Choices extends Component{
  constructor(props) {
    super(props); 
    this.state = { seg: 1, login:1 }; 
    } 
    render() { 
    const { navigate } = this.props.navigation; 
    return ( <Header hasSegment style={{
    backgroundColor:'#ff9102'
    }} androidStatusBarColor="#ed8702" iosBarStyle="light-content"> 
    <Button transparent onPress={() => this.props.navigation.goBack()} >
    <Title>Login</Title> 
    <Segment style={{
  backgroundColor:'#F5FCFF',display:'flex',height:50}}> 
    <Button first active={this.state.seg === 1 ? true:false} onPress={()=>this.setState({seg:1,login:1})} style={{flex:1,justifyContent:'center',height:60}} >
    JOBSEEKER 
    </Button>
    <Button last active={this.state.seg === 2 ? true : false} onPress={() => this.setState({ seg: 2,login:2 })} style={{
    flex:1,
    justifyContent:'center',
    height:60}} > 
    EMPLOYER 
     </Button>
    {this.state.seg === 1 && } {this.state.seg === 2 && }

      </Content>
    </ScrollView>
    </Container>
);
} }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F5FCFF', } });

Вот мой код страницы входа импортировать React, {Component} из 'response'; import {Platform, StyleSheet, Text, ScrollView} из'act-native '; import {Container, Content, View, Button} из «native-base»; импортировать t из 'tcomb-form-native'; var _ = require ('lodash'); const Form = t.form.Form; const stylesheet = _.cloneDeep (t.form.Form.stylesheet);

Form.stylesheet.textbox.normal.height = 50; Form.stylesheet.textbox.normal.marginBottom = 20; Form.stylesheet.textbox.normal.borderRadius = 30; Form.stylesheet.textbox.normal.paddingHorizont = 30; Form.stylesheet.textbox.normal.borderWidth = 2; Form.stylesheet.textbox.normal.fontSize = 20; Form.stylesheet.textbox.normal.color = '# 66747c';

var loginForm = t.struct({ email:t.String, password:t.String });

var formOptions = { 
  fields:{ 
    email:{ placeholder:'Email', }, 
    password:{ placeholder:'Password' }
  },
  auto:'none' 
}

export default class Login extends Component{
  constructor(props){ 
    super(props); 
    this.state = { seg: 1 };
  }
  render() { 
    alert(JSON.stringify(this.props)) 
    return ( 
      <View style={{flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}}> <Button rounded={true} large={true} style={{
      backgroundColor:'#ff9102',
      paddingHorizontal:30,flex:1,justifyContent:'center'}} > 
      <Text style={{fontSize:27,color:'#fff'}}>Login <View style{{flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}} 
      padder > 
      <Text style={{fontSize:17,justifyContent:'center'}}> Register a new account 
      <View style={{
      flex:1,flexDirection:'row',justifyContent:'center',alignItems:'center'}} padder > 
      <Button transparent onPress={()=>this.props.navigation.navigate('Forgot')} > <Text style={{fontSize:17,justifyContent:'center', color:'#ff9102'}}> 
      Forgot Password 
    ); 
  } 
}
const styles = StyleSheet.create(
{ 
container: { flex: 1, backgroundColor: '#F5FCFF', } })
;

Пожалуйста, помогите, что я делаю неправильно в этом коде.

...