Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

javascript - 在React-Native Formik onBlur()函数中调用prop和function(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.(但事实并非如此。)   ask by louisrtz translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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) }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...