Skip to content

Select input resets to passed in value when component re-renders #174

@semb09

Description

@semb09

Hi

I wonder if anyone can help. As I understand it, if you pass a 'value' into a controlled input component, the form HOC uses that to set the initial value of the input. On change of the input however, this value then gets overwritten and is controlled by react-validation.

Im running into an issue whereby if I pass an initial 'value' into a controlled Select component, every time the component re-renders (due to state change further up in the dom tree for example), the value gets reset to whatever was initially passed in.

This does not happen with text inputs, they retain their altered value but the select's do not.

If i do not pass a value to the controlled select component and the component is re-rendered, then the selection remains.

Does anyone have any idea how to get around this. When I am submitting my form currently, all the select boxes are resetting to their initial value (they need an initial value as this is an edit information page)

Thanks

Stephen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions