Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React Native TouchableWithoutFeedback不工作_Javascript_React Native - Fatal编程技术网

Javascript React Native TouchableWithoutFeedback不工作

Javascript React Native TouchableWithoutFeedback不工作,javascript,react-native,Javascript,React Native,我在键盘上创建了一个组件。不带反馈的可触摸包装其孩子。当有人在组件外单击时,键盘应该关闭。我做错了什么 DismissKeyboard.js const DismissKeyboard = ({children}) => ( <TouchableWithoutFeedback accessible={false} onPress={() => Keyboard.dismiss()} > {children} </Touchable

我在键盘上创建了一个组件。不带反馈的可触摸包装其孩子。当有人在组件外单击时,键盘应该关闭。我做错了什么

DismissKeyboard.js

const DismissKeyboard = ({children}) => (
  <TouchableWithoutFeedback
    accessible={false}
    onPress={() => Keyboard.dismiss()}
  >
    {children}
  </TouchableWithoutFeedback>
);
包装我的文本输入

<DismissKeyboard>
        <View style={styles.noteContainer}>
          <TextInput
            style={styles.noteTextInputStyling}
            multiline
            value={note}
            placeholder={'Tap to edit'}
            placeholderTextColor={globals.COLOR.textColor}
            onChangeText={(text) => {
              setNote(text);
            }}
          />
        </View>
      </DismissKeyboard>

我错过了什么?如果您有任何帮助,我们将不胜感激……

请尝试这样使用:

const DismissKeyboard = ({children}) => (
  <TouchableWithoutFeedback
    accessible={false}
    onPress={() => Keyboard.dismiss()}
  >
   <View>
    {children}
   </View>
  </TouchableWithoutFeedback>
);

试着像这样使用它:

const DismissKeyboard = ({children}) => (
  <TouchableWithoutFeedback
    accessible={false}
    onPress={() => Keyboard.dismiss()}
  >
   <View>
    {children}
   </View>
  </TouchableWithoutFeedback>
);
尝试使用键盘组合,避免视觉和无反馈触摸,如下所示。请注意使用Keyboard.Disclose而不是Keyboard.Disclose

import React from 'react';
import {
  Keyboard, KeyboardAvoidingView, TouchableWithoutFeedback,
} from 'react-native';

const DismissKeyboard = ({ children }) => (
  <TouchableWithoutFeedback style={{ flex: 1 }} onPress={Keyboard.dismiss}>
    <KeyboardAvoidingView behavior="padding" style={{ flex: 1 }}>
      {children}
    </KeyboardAvoidingView>
  </TouchableWithoutFeedback>
);
尝试使用键盘组合,避免视觉和无反馈触摸,如下所示。请注意使用Keyboard.Disclose而不是Keyboard.Disclose

import React from 'react';
import {
  Keyboard, KeyboardAvoidingView, TouchableWithoutFeedback,
} from 'react-native';

const DismissKeyboard = ({ children }) => (
  <TouchableWithoutFeedback style={{ flex: 1 }} onPress={Keyboard.dismiss}>
    <KeyboardAvoidingView behavior="padding" style={{ flex: 1 }}>
      {children}
    </KeyboardAvoidingView>
  </TouchableWithoutFeedback>
);

你的答案是赢家!你的答案是赢家!