redux-form / redux-form

A Higher Order Component using react-redux to keep form state in a Redux store
https://redux-form.com
MIT License
12.58k stars 1.64k forks source link

(REACT NATIVE) How to focus an Input in dispatch actions #4409

Open radouanedev opened 5 years ago

radouanedev commented 5 years ago

Hello guys. I ask you guys, how to focus an Input in dispatch actions (react native) ? I try to use this function inside my action but it doesn't work for me :

import { focus } from 'redux-form';

export const initSignup = () => (dispatch) => {
  dispatch(focus('myForm', 'email'));
};
seppestaes commented 5 years ago

Hi,

This works for me, at least it sets the field state to 'active'. Then in the render function of the 'CustomTextInput', I added:

{ formStates.filter((state) => meta[state]).map((state) => { if(state === 'active'){ this.refs.email.focus() } }) }

radouanedev commented 5 years ago

Thanks @seppestaes i wanted to focus it by actions creator but it doesn't works, so i did it with a simple reference then it is worked.