Search code examples
reactjsdynamicreduxdropdownredux-form

Redux form not getting re-rendered


I have a dynamic dropdown. I am fetching the dynamic values in componentWillMount method and setting in state. I'm setting the fetched values to props in mapStateToProps. Field:

<Field name="productId" component={this.renderDropdown} />

The problem that I am facing is when the state is updated with new values, the render method is called but the renderDropdown method is not getting called. So the dropdown is not getting populated with the values that I fetched.

Is there anything extra that I need to do to achieve this?


Solution

  • Pass the new data as props to Field . The props will get merged with Field default props. Some thing like this

    <Field
            name="productId"
            component={this.renderDropdown}
            newData={newData}
     />
    
    and access the newData props in your component defined in this.renderDropdown