Skip to content

Commit

Permalink
remove componentWillReceiveProps usage for concurrent mode (#527)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Chang <cht8687@gmail.com>
  • Loading branch information
eightypop and cht8687 committed Feb 25, 2020
1 parent 828846c commit 45db37a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Cleave.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,13 @@ var cleaveReactClass = CreateReactClass({

componentDidUpdate: function () {
var owner = this,
phoneRegionCode = (owner.props.options || {}).phoneRegionCode,
newValue = owner.props.value,
pps = owner.properties;

Util.setSelection(owner.element, owner.state.cursorPosition, pps.document);
},

componentWillReceiveProps: function (nextProps) {
var owner = this,
phoneRegionCode = (nextProps.options || {}).phoneRegionCode,
newValue = nextProps.value;

// update registed events
owner.updateRegisteredEvents(nextProps);

owner.updateRegisteredEvents(owner.props);
if (newValue !== undefined && newValue !== null) {

newValue = newValue.toString();

if (newValue !== owner.properties.result) {
Expand All @@ -46,6 +39,8 @@ var cleaveReactClass = CreateReactClass({
owner.initPhoneFormatter();
owner.onInput(owner.properties.result);
}

Util.setSelection(owner.element, owner.state.cursorPosition, pps.document);
},

updateRegisteredEvents: function (props) {
Expand Down

0 comments on commit 45db37a

Please sign in to comment.