Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Patrik Meijer
react-components
Commits
21b52577
Commit
21b52577
authored
Nov 08, 2018
by
Patrik Meijer
Browse files
Move over to getDerivedStateFromProps in attribute item
parent
649062fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/AttributeItem/AttributeItem.jsx
View file @
21b52577
...
...
@@ -58,11 +58,17 @@ export default class AttributeItem extends Component {
state
=
{
value
:
this
.
props
.
value
,
persistedValue
:
this
.
props
.
value
,
picking
:
false
,
};
componentWillReceiveProps
(
nextProps
)
{
this
.
setState
({
value
:
nextProps
.
value
,
picking
:
false
});
static
getDerivedStateFromProps
(
nextProps
,
prevState
)
{
// Note that outside property updates have precedence over typed in fields.
if
(
nextProps
.
value
!==
prevState
.
persistedValue
)
{
return
{
value
:
nextProps
.
value
,
persistedValue
:
nextProps
.
value
,
picking
:
false
}
}
return
null
;
}
onColorChange
=
(
color
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment