用户点击输入后键盘保持关闭状态

 收藏

The problems => https://drive.google.com/open?id=1KwBWMVsj-0PFzt9cLfLuZ9cTvkqjIob8

这是我的代码

export default function TextInp(props) {
  const [ansVal, setAnsVal] = useState(props.data.ans);

  const answer = (ans) => {
    setAnsVal(ans);
    props.answer(ans);
  };

  return (
    <View style={styles.view}>
      <TextInput
        placeholder={props.placeholder}
        style={props.free ? styles.freeContainer : styles.container}
        onChangeText={(text)=>answer(text)}
        defaultValue={ansVal}
      />
    </View>
  );
}

PS. the TextInput is inside ScrollView. I'm not sure if this is the cause of the problem.

回复