Skip to content

Commit 82982c7

Browse files
committed
fix re-mounting ParallaxProvider #9
1 parent f940f9d commit 82982c7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

example/components/App/App.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import React, { Component } from 'react';
2-
// import PropTypes from 'prop-types';
32
import { ParallaxProvider } from 'react-scroll-parallax';
43
import { ParallaxTest } from 'components';
54

65
export default class App extends Component {
6+
// this just serves to test unmount/re-mount ParallaxProvider
7+
state = {
8+
mount: true,
9+
};
10+
711
render() {
812
return (
9-
<ParallaxProvider>
10-
<ParallaxTest />
11-
</ParallaxProvider>
13+
<main>
14+
{this.state.mount ? (
15+
<ParallaxProvider>
16+
<ParallaxTest />
17+
</ParallaxProvider>
18+
) : (
19+
<div />
20+
)}
21+
</main>
1222
);
1323
}
1424
}

src/libs/ParallaxController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ function ParallaxController() {
389389
this.destroy = function() {
390390
_removeListeners();
391391
_removeParallaxStyles();
392+
window.ParallaxController = null;
392393
};
393394
}
394395

0 commit comments

Comments
 (0)