reactjsreduxredux-form

How to get current values of redux-form before submitting


I'm using redux-form library. When I'm just filling the form, in redux-store I can see that new field is created: "form" field, including all key-value pairs. If I change any value, the key-value pair changes too.

How can I get all key-value pairs from this "form" field?


Solution

  • You can use the getFormValues selector. Take a look at the documentation to see the usage.

    import { getFormValues } from 'redux-form'
    import { useSelector } from 'react-redux'
    
    ...
    
    const formValues = useSelector(state => getFormValues('my_form')(state))