Skip to content

Commit d5d435b

Browse files
committed
rm isinsideRender
1 parent 8931e1b commit d5d435b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-scroll-anim",
3-
"version": "2.6.0",
3+
"version": "2.6.1",
44
"description": "scroll-anim anim component for react",
55
"keywords": [
66
"react",

src/ScrollOverPack.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class ScrollOverPack extends ScrollElement {
3131
componentProps: {},
3232
}
3333

34-
static getDerivedStateFromProps(props, { prevProps, $self }) {
34+
static getDerivedStateFromProps(props, { prevProps }) {
3535
const nextState = {
3636
prevProps: props,
3737
};
38-
if (prevProps && !$self.isInsideRender) {
38+
if (prevProps && props !== prevProps) {
3939
nextState.children = toArrayChildren(props.children);
4040
}
4141
return nextState;
@@ -48,13 +48,12 @@ class ScrollOverPack extends ScrollElement {
4848
this.enter = false;
4949
this.state = {
5050
show: false,
51-
$self: this,
5251
children: toArrayChildren(props.children),
5352
};
5453
}
5554

56-
componentDidUpdate() {
57-
if (this.isInsideRender) {
55+
componentDidUpdate(prevProps) {
56+
if (prevProps !== this.props) {
5857
const { always } = this.props;
5958
const { show } = this.state;
6059
const inListener = EventListener._listeners.scroll &&
@@ -65,7 +64,6 @@ class ScrollOverPack extends ScrollElement {
6564
this.scrollEventListener();
6665
}
6766
}
68-
this.isInsideRender = false;
6967
}
7068

7169
scrollEventListener = (e) => {
@@ -75,7 +73,6 @@ class ScrollOverPack extends ScrollElement {
7573
const isTop = this.elementShowHeight > this.clientHeight + this.leavePlayHeight;
7674
if (this.enter || !replay && isTop) {
7775
if (!show) {
78-
this.isInsideRender = true;
7976
this.setState({
8077
show: true,
8178
});
@@ -89,7 +86,6 @@ class ScrollOverPack extends ScrollElement {
8986
const topLeave = replay ? isTop : null;
9087
if (topLeave || bottomLeave) {
9188
if (show) {
92-
this.isInsideRender = true;
9389
this.setState({
9490
show: false,
9591
});

0 commit comments

Comments
 (0)