小编Avi*_*ati的帖子

电子邮件验证(React Native).将结果返回为所有条目的"无效"

我试图通过对表达式进行检查来验证用户的电子邮件.但我得到的结果对所有条目都无效.

更新的代码

class dummytest extends Component{

  constructor(props){
    super(props);
    this.state = {
                email :'',
                validated: false ,
                 }
  };

go = () => {
           const reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
           if (reg.test(this.state.email) === true){
               alert( valid);
           }
           else{
               alert();
           }
 }
  render(){
       return(
         <View style={{alignSelf:'center',marginTop:100}}>
              <TextInput autoCapitalize="none" autoCorrect={false} style={{height:20,width:200,backgroundColor:'blue'}} value={this.setState.email}/>

              <Button onPress={this.go.bind(this)}>
                 <Text> GO </Text>
              </Button>
          </View>

       );
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript validation react-native react-native-ios

17
推荐指数
1
解决办法
4万
查看次数

null不是对象(评估this.state.count)

当我试图为每次按下按钮时设置计数时,我面临上述错误.

export default class ViewIdeas extends Component{
get InitialState(){
  return {
  count : 0
  }
}
render(){
    return(
   .......
 <Button transparent>
             <Icon name='ios-thumbs-up-outline' style={{fontSize:21}} 
              onPress={() => this.setState({count: ++this.state.count})}/>
              <Text>{'Like' + this.state.count}</Text>
    </Button>
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

13
推荐指数
1
解决办法
1万
查看次数

在React Native中向onPress函数添加多个事件

当我按下按钮时,它应该导航到另一个页面,它也会增加查看次数.

但我无论如何都无法理解同时实施它们.

这是我的代码:

<Button onPress={Actions.ideaOnClick}>
<Button onPress={() => this.setState({views: ++this.state.views})}>
Run Code Online (Sandbox Code Playgroud)

button react-native react-native-android react-native-ios react-navigation

7
推荐指数
2
解决办法
2万
查看次数

未定义不是对象(评估'imagePicker.openPicker')

我正在尝试使用 react-native-image-crop-picker。代码如下。我已经尝试过 npm install react-native-image-crop-picker@latest。

每当我选择任何一个未定义的选项时,都不会显示对象(正在评估“imagePicker.openPicker”)。请帮助解决这个问题。

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

var ImagePicker = NativeModules.ImageCropPicker;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  button: {
    backgroundColor: 'blue',
    marginBottom: 10
  },
  text: {
    color: 'white',
    fontSize: 20,
    textAlign: 'center'
  }
});

export default class Upload extends Component {

  constructor() {
    super();
    this.state = {
      image: null,
      images: null
    };
  }

  pickSingleWithCamera(cropping) { …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

6
推荐指数
2
解决办法
6784
查看次数