Skip to content

Commit

Permalink
fix: TextField value prop not updating internal text state
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel committed Dec 9, 2020
1 parent b6e32ab commit b28dead
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ export default class TextField extends PureComponent {
y1: 0,
}

static getDerivedStateFromProps({ error }, state) {
static getDerivedStateFromProps({ error, value }, state) {
let newState = {}
/* Keep last received error in state */
if (error && error !== state.error) {
return { error }
newState.error = error
}

return null
if (value !== state.text) {
newState.text = value
}

return newState
}

constructor(props) {
Expand Down

0 comments on commit b28dead

Please sign in to comment.