Skip to content

Commit

Permalink
Revert "Merge pull request #129 from tstirrat15/remove-will-receive-p…
Browse files Browse the repository at this point in the history
…rops"

This reverts commit 6104749, reversing
changes made to e242534.
  • Loading branch information
dreyescat committed Nov 27, 2019
1 parent fe11de2 commit e83987c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/Rating.js
Expand Up @@ -17,11 +17,11 @@ class Rating extends React.PureComponent {
this.symbolClick = this.symbolClick.bind(this);
}

static getDerivedStateFromProps(props, prevState) {
const { value } = props;
return (value === prevState.displayValue)
? { displayValue: value }
: null;
UNSAFE_componentWillReceiveProps(nextProps) {
const valueChanged = this.props.value !== nextProps.value;
this.setState((prevState) => ({
displayValue: valueChanged ? nextProps.value : prevState.displayValue
}));
}

componentDidUpdate(prevProps, prevState) {
Expand Down
9 changes: 4 additions & 5 deletions src/RatingAPILayer.js
Expand Up @@ -14,11 +14,10 @@ class RatingAPILayer extends React.PureComponent {
this.handleHover = this.handleHover.bind(this);
}

static getDerivedStateFromProps(props, prevState) {
const { initialRating } = props;
return (initialRating !== prevState.value)
? { value: initialRating }
: null;
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState({
value: nextProps.initialRating
});
}

handleClick(value, e) {
Expand Down
6 changes: 3 additions & 3 deletions test/Rating-test.js
Expand Up @@ -60,20 +60,20 @@ describe('Rating', function () {
});

it('should have all symbols readonly', function () {
rating.props.children.forEach(function (symbol) {
rating.props.children.forEach(function (symbol, i) {
expect(symbol.props.readonly).to.be.false;
});
});
it('should not have mouse move handler', function () {
var noop = require('../src/utils/noop');
rating.props.children.forEach(function (symbol) {
rating.props.children.forEach(function (symbol, i) {
expect(symbol.props.onMouseMove).to.equal(noop);
});
});

it('should not have click handler', function () {
var noop = require('../src/utils/noop');
rating.props.children.forEach(function (symbol) {
rating.props.children.forEach(function (symbol, i) {
expect(symbol.props.onClick).to.equal(noop);
});
});
Expand Down

0 comments on commit e83987c

Please sign in to comment.