标签: react-native-ios

undefined 不是一个对象(评估'this.props.navigation.navigate')react-native

我发现各种类似的问题都有不同的问题和解决方案。在大多数情况下,似乎项目架构是罪魁祸首。我无法弄清楚我的。我想导航到Signup screen点击获取 OTP 按钮PhoneSignup screen

在此处输入图片说明

电话注册表格.js

export default class PhoneSignupForm extends Component {    
      render() {
        return (
            <View >
               <TouchableOpacity 
                  onPress={ () => this.props.navigation.navigate('Signup') }
                >
                  <Text>
                    Get OTP
                  </Text>
              </ TouchableOpacity>
            </View>
        );
      }
    }
Run Code Online (Sandbox Code Playgroud)

电话注册.js

import PhoneSignupForm from './PhoneSignupForm';

export default class PhoneSignup extends Component {
  render() {
    return (
        <View style = {styles.container}>
            <View style = {styles.logoContainer}>
                <Image
                    style = {styles.logo}
                    source = {require('../../icons/hp.png') }
                />
                <Text style = {styles.title}>Hewlett-Packard</Text> 
            </View>
            <View style …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios react-navigation

0
推荐指数
1
解决办法
9639
查看次数

com.facebook.react.bridge.ReadableNativeMap 不能转换为 java.lang.Double

我正在使用 React 的 fetch() 方法登录到我的服务。到目前为止,我已经完成了以下工作,您可以查看我的东西:

_callApiForLogin = () => {
ToastAndroid.show('Logging In...', ToastAndroid.SHORT);

let data = new FormData();
data.append('username', "sssss");
data.append('password', "123456");
data.append('device_token', "hjkhjkhjkkksdkjhkjhksdsfs");
data.append('device_type', "2");

fetch('https://612.33.196.54/~yes/master/api/web/login', {

  method: 'POST',

  body: data,

}).then((response) => response.json())
  .then((responseJson) => {
    ToastAndroid.show('Logging In...', responseJson);
    if (responseJson.status === '1') {
      ToastAndroid.show('Logging Successful' + responseJson, ToastAndroid.SHORT);
    }
    return responseJson.status;
  })
  .catch((error) => {
    console.error(error);
  });
  }
Run Code Online (Sandbox Code Playgroud)

但是,响应低于错误。

错误:com.facebook.react.bridge.ReadableNativeMap 无法转换为 java.lang.Double

来自服务的响应如下:

{
    "status": 1,
    "data": {
        "id": "551",
        "first_name": "sssss",
        "last_name": "lastname",
        "email": "ja@gmail.com",
        "username": …
Run Code Online (Sandbox Code Playgroud)

fetch react-native react-native-android react-native-ios

0
推荐指数
1
解决办法
7316
查看次数

如何在 TextInput 中添加前缀 - React Native

我想在我的文本输入中添加前缀,我想知道如何做到这一点。

文本输入代码

        <TextInput
          style={styles.inputs}
          placeholder="Mobile Number"
          keyboardType="number-pad"
          underlineColorAndroid="transparent"
          onChangeText={mobile_number => this.setState({mobile_number})}
        />
Run Code Online (Sandbox Code Playgroud)

我想要的最终输出

维

textinput react-native react-native-ios

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

React-Native-Image-Picker 对话框在 IOS 中启动后自动关闭

描述

我正在使用 React-Native-Image-Picker 从我的应用程序中选择和上传文件,我面临的问题是它在 Android 中工作,但在 ios 中,react-native-image-picker 对话框在启动后自动关闭,因此我无法选择供上传的文件。ios 文件上传所需的所有权限也已被授予。

React-Native-image-picker 对话框

如何重复问题和示例

import ImagePicker from 'react-native-image-picker';
import RNFetchBlob from 'react-native-fetch-blob';

var options = {
      title: 'Select Image',
      quality : 0.25,
      storageOptions: {
        skipBackup: true,
        path: 'images',
      },
    };
  ImagePicker.showImagePicker(options, response => {
      console.log('Response = ', response);

      RNFetchBlob.fs.stat(response.path)
      .then((stats) => {
        if (stats.size <= 5000000) {
          let source = response;
          let checkboxStates = {...this.state.checkboxStates}; 
          checkboxStates['image'] = true;

          this.setState({ imagePath: source, imageVisible: true, totalUploadSize: this.state.totalUploadSize + stats.size });   
          this.setState({checkboxStates});
        }
        else{
          toastMessage('Image should …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios react-native-image-picker

0
推荐指数
2
解决办法
2758
查看次数

我收到 npm run ios 命令的错误

当我编写此命令“npm run ios”时,出现此错误:

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening PhotoSearch.xcworkspace. Run CLI with --verbose flag for more details.
User defaults from command line:
    IDEDerivedDataPathOverride = /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch

note: Using new build system
note: Planning build
note: Constructing build description
Build system information
error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Zocial.ttf':
1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' …
Run Code Online (Sandbox Code Playgroud)

ios react-native react-native-ios

0
推荐指数
1
解决办法
861
查看次数

React Navigation - this.props.navigation.state 未定义

使用:“@react-navigation/drawer”:“^5.4.0”,“@react-navigation/native”:“^5.1.4”,

应用程序.js:

    import { createDrawerNavigator } from '@react-navigation/drawer';
    ...
    const Drawer = createDrawerNavigator();
    const DrawerRender = () => {
    return (
      <NavigationContainer>
        <Drawer.Navigator drawerContent={props => <DrawerContent {...props} />}>
          <Drawer.Screen name="Home" component={Home} />
          <Drawer.Screen name="Screen1" component={Screen1} options={{unmountOnBlur: true, gestureEnabled: false}} />
          <Drawer.Screen name="Screen2" component={Screen2} options={{unmountOnBlur: true, gestureEnabled: false}} />
        </Drawer.Navigator>
      </NavigationContainer>
    );}
Run Code Online (Sandbox Code Playgroud)

从屏幕 1:

    navigateToPage = page_id => {
      this.closeCommentScreen();
      this.reopenModal = true;
      this.props.navigation.navigate('Screen2', {'page_id': 'testing'});
    }
Run Code Online (Sandbox Code Playgroud)

在屏幕 2 上:

    export default class Screen2 extends React.Component {

    constructor(props) {
       super(props);
    } …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios react-navigation

0
推荐指数
1
解决办法
4512
查看次数

如何忽略 React Native 应用程序的“辅助功能”设置?

当我在 iOS 设置中激活“常规 -> 辅助功能”中的“粗体文本”时,一些文本会被裁剪,因为它们变得更大,从而超出了预期的显示区域。

此外,如果我放大“辅助功能 - > 大文本”中的所有文本,突然间,我的应用程序变得完全无法使用,因为所有内容都被向各个方向裁剪,文本占用了大量空间。

但是,当我启用这些设置并转到 TikTok、Wishbones 等应用程序时……我注意到它们似乎不受这些系统更改的影响。

现在没有时间设置所有内容以使我的应用程序响应这些设置,我想知道这些应用程序如何“忽略”这些设置?

accessibility react-native react-native-android react-native-ios

0
推荐指数
1
解决办法
1400
查看次数

运行 react-native run-android --variant=release 后构建失败

任务 执行失败':app:installRelease'

com.android.builder.testing.api.DeviceException:
com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK: Package
couldn't be installed in /data/app/com.example: Package
/data/app/com.example/base.apk code is missing
Run Code Online (Sandbox Code Playgroud)

android react-native react-native-android react-native-ios

0
推荐指数
1
解决办法
617
查看次数

将 useEffect 与类组件一起使用

我有一个类用于呈现数据库中的用户列表

    export default class Users extends React.Component {
    
      constructor() {
        super()
      this.state = {
          data : [] //define a state  

        }
      }
    
    renderUsers = () => {
        useEffect(() => {
          fetch('exemple.com')
            .then((response) => response.json())
            .then((json) => this.setState({data: json.result})) // set returned values into the data state
            .catch((error) => console.error(error))
        }, []);
    
       return  this.state.data.map((value,key)=>{ // map state and return some views 
            ......
          })
     }
    
     render() {
        return (
                 <View style={{ flex: 1 }}>
              {this.renderUsers()} //render results
            </View>
    
        );
      }
    }
Run Code Online (Sandbox Code Playgroud)

问题是这段代码会抛出以下错误: …

javascript react-native react-native-android react-native-ios

0
推荐指数
1
解决办法
2010
查看次数

运行react-native run-android时,配置项目':react-native-audio-recorder-player' &gt;compileSdkVersion未指定时出现问题

每当我尝试运行react-native run-android时,我都会收到以下错误:

A problem occurred configuring project ':react-native-audio-recorder-player'.
> compileSdkVersion is not specified.
Run Code Online (Sandbox Code Playgroud)

构建.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
    minSdkVersion = 21
    compileSdkVersion = 28
    targetSdkVersion = 28
    
    androidXAnnotation = "1.1.0"
    androidXBrowser = "1.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    } …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios

0
推荐指数
1
解决办法
8953
查看次数

无法处理“npm install -g create-react-native-app”

我刚开始学习 React Native。我已经在我的 Mac 上安装了 Node.js,然后我尝试通过命令“npm install -g create-react-native-app”(我按照其官方网站上的安装指南)安装 React Native。但在那之后,出现了以下消息:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-ios

-1
推荐指数
1
解决办法
2304
查看次数