[英]Calling prop and function in React-Native formik onBlur() function
At the moment I am trying to call a function and the formikProps in my onBlur TextInput
function at the same time.目前我正在尝试同时在我的 onBlur TextInput
函数中调用一个函数和 formikProps 。
<TextInput
onBlur={() => {
formikProps.handleBlur('password')
setFocused(false)
}
/>
What I want to achieve:我想要实现的目标:
When I am leaving the Textinput I change the state of isFocused to true, because I want that the styles change at this moment.当我离开Textinput时,我将isFocused的状态更改为 true,因为我希望此时更改样式。 As well my Textinput should fire handleBlur().我的 Textinput 也应该触发 handleBlur()。 But it doesn't.但事实并非如此。
this doesn't work for multiline={true}
.这不适用于multiline={true}
。 And you should use the onEndEditing
method instead of the onBlur
你应该使用onEndEditing
方法而不是onBlur
onEndEditing?: function Callback that is called when text input ends. onEndEditing?: 文本输入结束时调用的回调函数。
onEndEditing={(e) => {
formikProps.handleBlur('password')
setFocused(false)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.