小编Mit*_*man的帖子

当应用程序在调试模式下运行时,本机按钮 OnPress 不会触发

我遇到了一个奇怪的问题。当我在调试模式下运行我的应用程序时,我的按钮中的 onPress 处理程序不会触发。当我停止在调试模式下运行应用程序时,按钮按预期工作。

调试在我的模拟器上工作,但在真实设备上失败。

细节:

OS: Mac
react: "16.11.0"
react-native: "0.62.2"
Run Code Online (Sandbox Code Playgroud)

代码

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
import {
  Button,
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const App = () => {
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView
          contentInsetAdjustmentBehavior="automatic"
          style={styles.scrollView}>
          <Header />
          {global.HermesInternal == null ? null : (
            <View style={styles.engine}> …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-debugger

13
推荐指数
2
解决办法
2263
查看次数