Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 3c84dc6

Browse files
committed
fix(life cycle mount): rm willUmount hooks
route change will cause didMount/willUmount called
1 parent b01b4f0 commit 3c84dc6

File tree

16 files changed

+11
-89
lines changed

16 files changed

+11
-89
lines changed

containers/CheatsheetThread/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ class CheatsheetThreadContainer extends React.Component {
5252
}, 1000)
5353
}
5454

55-
componentWillUnmount() {
56-
logic.uninit()
57-
}
58-
5955
render() {
6056
const { cheatsheetThread } = this.props
6157
const { cheatsheetData, curView, curCommunity } = cheatsheetThread

containers/CheatsheetThread/logic.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ const ErrSolver = [
101101
export function init(_store) {
102102
store = _store
103103

104-
if (sub$) sub$.unsubscribe()
104+
if (sub$) return false
105105
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
106106
getCheatsheet()
107107
}
108-
109-
export function uninit() {
110-
if (sub$) sub$.unsubscribe()
111-
}

containers/JobsThread/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class JobsThreadContainer extends React.Component {
4242
logic.init(jobsThread)
4343
}
4444

45-
componentWillUnmount() {
46-
logic.uninit()
47-
}
48-
4945
render() {
5046
const { jobsThread } = this.props
5147

containers/JobsThread/logic.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ const debug = makeDebugger('L:JobsThread')
3434
let store = null
3535
let sub$ = null
3636

37-
const validFilter = R.pickBy(
38-
R.compose(
39-
R.not,
40-
R.isEmpty
41-
)
42-
)
37+
const validFilter = R.pickBy(R.compose(R.not, R.isEmpty))
4338

4439
export const inAnchor = () => store.setHeaderFix(false)
4540
export const outAnchor = () => store.setHeaderFix(true)
@@ -158,10 +153,6 @@ const ErrSolver = [
158153
export function init(_store) {
159154
store = _store
160155

161-
if (sub$) sub$.unsubscribe()
156+
if (sub$) return false // sub$.unsubscribe()
162157
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
163158
}
164-
165-
export function uninit() {
166-
if (sub$) sub$.unsubscribe()
167-
}

containers/PostsThread/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class PostsThreadContainer extends React.Component {
4848

4949
// componentWillUnmount will be called everytime when route changes
5050
// so don't use
51-
componentWillUnmount() {
52-
// logic.uninit()
53-
}
51+
componentWillUnmount() {}
5452

5553
render() {
5654
const { postsThread } = this.props

containers/PostsThread/logic.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,3 @@ export function init(_store) {
187187
if (sub$) return false // sub$.unsubscribe()
188188
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
189189
}
190-
191-
export function uninit() {
192-
// debug('======== un init')
193-
// if (sub$) sub$.unsubscribe()
194-
}

containers/ReposThread/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class ReposThreadContainer extends React.Component {
4242
logic.init(reposThread)
4343
}
4444

45-
componentWillUnmount() {
46-
logic.uninit()
47-
}
48-
4945
render() {
5046
const { reposThread } = this.props
5147

containers/ReposThread/logic.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ const debug = makeDebugger('L:ReposThread')
3232

3333
let store = null
3434

35-
const validFilter = R.pickBy(
36-
R.compose(
37-
R.not,
38-
R.isEmpty
39-
)
40-
)
35+
const validFilter = R.pickBy(R.compose(R.not, R.isEmpty))
4136

4237
export const inAnchor = () => store.setHeaderFix(false)
4338
export const outAnchor = () => store.setHeaderFix(true)
@@ -131,10 +126,6 @@ const ErrSolver = []
131126
export function init(_store) {
132127
store = _store
133128

134-
if (sub$) sub$.unsubscribe()
129+
if (sub$) return false
135130
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
136131
}
137-
138-
export function uninit() {
139-
if (sub$) sub$.unsubscribe()
140-
}

containers/UsersThread/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ class UsersThreadContainer extends React.Component {
4747
})
4848
}
4949

50-
componentWillUnmount() {
51-
logic.uninit()
52-
}
53-
5450
render() {
5551
const { usersThread } = this.props
5652
const { geoInfosData, geoDataLoading, curTheme } = usersThread

containers/UsersThread/logic.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ const ErrSolver = [
6060
export function init(_store) {
6161
store = _store
6262

63-
if (sub$) sub$.unsubscribe()
63+
if (sub$) return false
6464
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
6565
loadGeoData()
6666
}
67-
68-
export function uninit() {
69-
if (sub$) sub$.unsubscribe()
70-
}

0 commit comments

Comments
 (0)