Using redux-form I'm losing focus after typing the first character

后端 未结 7 682
甜味超标
甜味超标 2020-12-24 12:40

I\'m using redux-form and on blur validation. After I type the first character into an input element, it loses focus and I have to click in it again to continue

7条回答
  •  抹茶落季
    2020-12-24 13:03

    I had the same problem, and none of the answers worked for me. But thanks to Advem's answer I got an idea of what could be wrong: My form required accordion UI, and for that I had state variable in it:

    const ConveyorNotificationSettingsForm = (props) => {
        const {handleSubmit, formValues, dirty, reset, submitting} = props;
        const [expandedSection, setExpandedSection] = useState(null);
    ...
    

    with only one expanded section, that with its index equal to expandedSection .

    After I extracted the accordion to a separate functional component and moved useState there, the problem was gone.

提交回复
热议问题