Closed mnazim closed 8 years ago
tcomb-form
implements shouldComponentUpdate
in a way similar to PureRenderMixin, using ===
comparisons, so options
must be treated as immutable data structures (i.e. return a new copy with changed references). My guess is that, since you are mutating formOptions
, the form doesn't trigger a re-rendering.
Tip: you might want to use the provided immutability helpers or a library of your choice in order to do less work.
@gcanti
Thank you, good sir! That was it. formOptions
with a new reference was need.
Version
What I am trying to do
Based on the data I receive from the API, I need to set errors per field and set the form in error state. I am doing this with redux and I get the API response in
props.signup
. I am usingcomponentWillReceiveProps
to check for errors innextProps.signup
and set errors accordingly.The problem
I can confirm the new
this.state.formOptions
being set incomponentWillReceiveProps
andrender
being called again, but the form itself does not render in error state.Form is only set in error state when I edit a field for which an
hasError = true
has been set incomponentWillReceiveProps
. Say, I got error from the server foremail
field, "email has already been used to register an account"; the moment I edit email field, the errors I set incomponentWillReceiveProps
only foremail
field are displayed.What am I doing wrong?
The Component