diff options
author | 2018-12-08 23:42:49 +0100 | |
---|---|---|
committer | 2018-12-08 23:42:49 +0100 | |
commit | d15efc6ba99ab26735dcf7a83303ab0b148ecd46 (patch) | |
tree | 8d9418351b9cc5cd394b9fa41ee248dae0361c1d | |
parent | Fix linting issues (diff) | |
download | ferdium-app-d15efc6ba99ab26735dcf7a83303ab0b148ecd46.tar.gz ferdium-app-d15efc6ba99ab26735dcf7a83303ab0b148ecd46.tar.zst ferdium-app-d15efc6ba99ab26735dcf7a83303ab0b148ecd46.zip |
Dispose autorun on component unmount
-rw-r--r-- | src/components/services/content/ServiceWebview.js | 7 | ||||
-rw-r--r-- | src/containers/settings/RecipesScreen.js | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index 3ec0c3a67..f59205c0e 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js | |||
@@ -33,7 +33,7 @@ export default @observer class ServiceWebview extends Component { | |||
33 | }; | 33 | }; |
34 | 34 | ||
35 | componentDidMount() { | 35 | componentDidMount() { |
36 | autorun(() => { | 36 | this.autorunDisposer = autorun(() => { |
37 | if (this.props.service.isActive) { | 37 | if (this.props.service.isActive) { |
38 | this.setState({ forceRepaint: true }); | 38 | this.setState({ forceRepaint: true }); |
39 | setTimeout(() => { | 39 | setTimeout(() => { |
@@ -43,6 +43,10 @@ export default @observer class ServiceWebview extends Component { | |||
43 | }); | 43 | }); |
44 | } | 44 | } |
45 | 45 | ||
46 | componentWillUnmount() { | ||
47 | this.autorunDisposer(); | ||
48 | } | ||
49 | |||
46 | updateTargetUrl = (event) => { | 50 | updateTargetUrl = (event) => { |
47 | let visible = true; | 51 | let visible = true; |
48 | if (event.url === '' || event.url === '#') { | 52 | if (event.url === '' || event.url === '#') { |
@@ -54,6 +58,7 @@ export default @observer class ServiceWebview extends Component { | |||
54 | }); | 58 | }); |
55 | } | 59 | } |
56 | 60 | ||
61 | autorunDisposer = null; | ||
57 | webview = null; | 62 | webview = null; |
58 | 63 | ||
59 | render() { | 64 | render() { |
diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index 4efe81505..b125e6a05 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js | |||
@@ -32,7 +32,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
32 | componentDidMount() { | 32 | componentDidMount() { |
33 | gaPage('Settings/Recipe Dashboard/Featured'); | 33 | gaPage('Settings/Recipe Dashboard/Featured'); |
34 | 34 | ||
35 | autorun(() => { | 35 | this.autorunDisposer = autorun(() => { |
36 | const { filter } = this.props.params; | 36 | const { filter } = this.props.params; |
37 | const { currentFilter } = this.state; | 37 | const { currentFilter } = this.state; |
38 | 38 | ||
@@ -51,8 +51,11 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
51 | 51 | ||
52 | componentWillUnmount() { | 52 | componentWillUnmount() { |
53 | this.props.stores.services.resetStatus(); | 53 | this.props.stores.services.resetStatus(); |
54 | this.autorunDisposer(); | ||
54 | } | 55 | } |
55 | 56 | ||
57 | autorunDisposer = null; | ||
58 | |||
56 | searchRecipes(needle) { | 59 | searchRecipes(needle) { |
57 | if (needle === '') { | 60 | if (needle === '') { |
58 | this.resetSearch(); | 61 | this.resetSearch(); |