我想在显示键盘时隐藏我的按钮,并在用户关闭键盘时将其移回。它可以工作,但是我注意到跳跃按钮的效果非常好,真的是难看的0.0001动画。我认为问题之所以存在,是因为我的代码在组件重新渲染之后就隐藏了元素。您能帮我避免这种“跳跃”吗?
const [isKeyboardVisible, setKeyboardVisible] = React.useState();
useEffect(() => {
Keyboard.addListener('keyboardDidShow', function() {
setKeyboardVisible(false);
});
Keyboard.addListener('keyboardDidHide', function() {
setKeyboardVisible(true);
});
});
{isKeyboardVisible && (
<Button
style={{
position: 'absolute',
borderRadius: 0,
bottom: 0,
width: '100%',}}
title="Delete"
}}
/>
)}