Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: non-existed lifecycle UNSAFE_componentWillUnmount #1615

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/__tests__/__snapshots__/CenterMode.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`CenterMode Tests Activity test 1`] = `
<h2>Center Mode</h2>
<div class=\\"slick-slider center slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\" style=\\"padding: 0px 60px;\\">
<div class=\\"slick-track\\" style=\\"width: -640px; opacity: 1; transform: translate3d(160px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"width: -640px; opacity: 1; transform: translate3d(160px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-4\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: -40px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -119,7 +119,8 @@ exports[`CenterMode Tests Activity test 1`] = `
</div>
</div>
</div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button></div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button>
</div>
</div>"
`;

Expand Down Expand Up @@ -242,7 +243,8 @@ exports[`CenterMode Tests Counting test 1`] = `
</div>
</div>
</div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button></div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button>
</div>
</div>"
`;

Expand Down Expand Up @@ -365,6 +367,7 @@ exports[`CenterMode Tests Positioning test 1`] = `
</div>
</div>
</div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button></div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button>
</div>
</div>"
`;
8 changes: 5 additions & 3 deletions examples/__tests__/__snapshots__/FocusOnSelect.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ exports[`FocusOnSelect Tests Activity Test 1`] = `
</div>
</div>
</div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button></div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button>
</div>
</div>"
`;

Expand All @@ -123,7 +124,7 @@ exports[`FocusOnSelect Tests Activity Test 2`] = `
<div>Click on any slide to select and make it current slide</div>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -230,6 +231,7 @@ exports[`FocusOnSelect Tests Activity Test 2`] = `
</div>
</div>
</div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button></div>
</div><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-next\\" style=\\"display: block;\\"> Next</button>
</div>
</div>"
`;
8 changes: 4 additions & 4 deletions examples/__tests__/__snapshots__/MultipleItems.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ exports[`Multiple Items should show last 3 slides when last dot is clicked 1`] =
<h2> Multiple items </h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -825,7 +825,7 @@ exports[`Multiple Items should show last 3 slides when previous button is clicke
<h2> Multiple items </h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -1153,7 +1153,7 @@ exports[`Multiple Items should show slides from 4 to 6 when middle dot is clicke
<h2> Multiple items </h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -1317,7 +1317,7 @@ exports[`Multiple Items should show slides from 4 to 6 when next button is click
<h2> Multiple items </h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down
6 changes: 3 additions & 3 deletions examples/__tests__/__snapshots__/SimpleSlider.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`Simple Slider Snapshots click on 3rd dot 1`] = `
<h2> Single Item</h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-1\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -116,7 +116,7 @@ exports[`Simple Slider Snapshots click on next button 1`] = `
<h2> Single Item</h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-1\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -227,7 +227,7 @@ exports[`Simple Slider Snapshots click on prev button 1`] = `
<h2> Single Item</h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-1\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down
4 changes: 2 additions & 2 deletions examples/__tests__/__snapshots__/UnevenSets.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`UnevenSets Finite Activity test 1`] = `
<h2>Uneven sets (finite)</h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"0\\" class=\\"slick-slide\\" tabindex=\\"-1\\" aria-hidden=\\"true\\" style=\\"outline: none; width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down Expand Up @@ -179,7 +179,7 @@ exports[`UnevenSets Infinite Activity test 1`] = `
<h2>Uneven sets (infinite)</h2>
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
<div class=\\"slick-list\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
<div data-index=\\"-4\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
<div>
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">
Expand Down
2 changes: 1 addition & 1 deletion src/inner-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class InnerSlider extends React.Component {
window.attachEvent("onresize", this.onWindowResized);
}
};
UNSAFE_componentWillUnmount = () => {
componentWillUnmount = () => {
if (this.animationEndCallback) {
clearTimeout(this.animationEndCallback);
}
Expand Down
2 changes: 1 addition & 1 deletion src/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Slider extends React.Component {
}
}

UNSAFE_componentWillUnmount() {
componentWillUnmount() {
this._responsiveMediaHandlers.forEach(function(obj) {
enquire.unregister(obj.query, obj.handler);
});
Expand Down