Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(compat): upgrade Panel lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Apr 8, 2019
1 parent 5ff2f51 commit d7128dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ class PanelCallbackHandler extends Component {
setCanRefine: PropTypes.func,
};

componentWillMount() {
// @TODO: didMount? -> really test this
componentDidMount() {
if (this.context.setCanRefine) {
this.context.setCanRefine(this.props.canRefine);
}
}

componentWillReceiveProps(nextProps) {
// @TODO: DidUpdate
componentDidUpdate(prevProps) {
if (
this.context.setCanRefine &&
this.props.canRefine !== nextProps.canRefine
prevProps.canRefine !== this.props.canRefine
) {
this.context.setCanRefine(nextProps.canRefine);
this.context.setCanRefine(this.props.canRefine);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('PanelCallbackHandler', () => {
expect(wrapper).toMatchSnapshot();
});

describe('willMount', () => {
describe('didMount', () => {
it('expect to call setCanRefine when the context is given', () => {
const props = {
canRefine: true,
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('PanelCallbackHandler', () => {
});
});

describe('willReceiveProps', () => {
describe('didUpdate', () => {
it('expect to call setCanRefine when the context is given', () => {
const props = {
canRefine: true,
Expand Down

0 comments on commit d7128dc

Please sign in to comment.