1

I am building a form using React and Redux Form. I use the formValueSelector to connect to several input fields. However, when I update these input fields in the UI, the form is not re-rendered. My code looks like this:

// HelpForm.jsx

import React from 'react';
import { connect } from 'react-redux';
import { reduxForm, formValueSelector } from 'redux-form';

import CategorySelectBlock from 'apps/help_form/components/CategorySelectBlock';

const selector = formValueSelector('help_form');

const mapStateToProps = state => ({
    category: selector(state, 'category'),
    subcategory: selector(state, 'subcategory')
});

class HelpForm extends React.Component {
    render() {
        const {
            category,
            subcategory
        } = this.props;

        console.log('Rendering HelpForm');
        console.log('category:', category);
        console.log('subcategory:', subcategory);

        return (
            <form id="helpform">
                <CategorySelectBlock
                    category={category}
                    subcategory={subcategory}
                />
            </form>
        );
    }
}

const ReduxHelpForm = reduxForm({
    form: 'help_form'
})(HelpForm);

export default connect(
    mapStateToProps
)(ReduxHelpForm);

I can see from my console logs that this HelpForm component is only rendering once, even after I select a new value for the category or subcategory fields (these are defined within the CategorySelectBlock component).

Am I doing something wrong, or misunderstanding how formValueSelector works? Any guidance would be much appreciated. Thank you!

1 Answer 1

1

I figured it out. I wasn't passing the onChange property through my custom input type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.