Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit 85fc576

Browse files
authored
Merge pull request #547 from firstred/componentwillmount
chore: move deprecated componentWillMount calls to constructor
2 parents 9c08436 + a922972 commit 85fc576

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/react/Components/Layout.jsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ class Layout extends React.Component {
6767
initialBunqJSClientRun: false
6868
};
6969

70-
this.activityTimer = null;
70+
this.checkLanguageChange(this.props);
71+
72+
if (this.minuteTimer) {
73+
clearInterval(this.minuteTimer);
74+
}
7175
this.minuteTimer = null;
7276

77+
this.activityTimer = null;
78+
7379
ipcRenderer.on("change-path", (event, path) => {
7480
const currentPath = this.props.history.location.pathname;
7581

@@ -129,14 +135,6 @@ class Layout extends React.Component {
129135
this.minuteTimer = setInterval(this.checkTime, 5000);
130136
}
131137

132-
componentWillMount() {
133-
this.checkLanguageChange(this.props);
134-
135-
// unset the minuteTimer when set
136-
if (this.minuteTimer) clearInterval(this.minuteTimer);
137-
this.minuteTimer = null;
138-
}
139-
140138
componentWillUpdate(nextProps) {
141139
// make sure language is up-to-date
142140
this.checkLanguageChange(nextProps);

src/react/Pages/RulePage/RulePage.jsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,54 @@ import { openSnackbar } from "../../Actions/snackbar";
1515
class RulesPage extends React.Component {
1616
constructor(props, context) {
1717
super(props, context);
18-
this.state = {
18+
19+
let initialState = {
1920
previewRuleCollection: null,
2021
previewUpdated: new Date(),
21-
2222
checkedInitial: false,
23-
24-
initialRules: false
23+
initialRules: false,
2524
};
26-
}
2725

28-
componentWillMount() {
2926
const searchParams = new URLSearchParams(this.props.location.search);
3027
if (searchParams.has("value")) {
3128
const value = searchParams.get("value");
3229
const field = searchParams.get("field") || "DESCRIPTION";
3330

34-
this.setState({
31+
initialState = {
32+
...initialState,
3533
checkedInitial: true,
3634
initialRules: [
3735
{
3836
ruleType: "VALUE",
3937
field: field,
4038
matchType: "CONTAINS",
4139
value: value
42-
}
43-
]
44-
});
40+
},
41+
],
42+
};
4543
} else if (searchParams.has("amount")) {
4644
const amount = searchParams.get("amount");
4745
const match_type = searchParams.get("match_type") || "EXACTLY";
4846

49-
this.setState({
47+
initialState = {
48+
...initialState,
5049
checkedInitial: true,
5150
initialRules: [
5251
{
5352
ruleType: "TRANSACTION_AMOUNT",
5453
matchType: match_type,
55-
amount: amount
56-
}
57-
]
58-
});
54+
amount: amount,
55+
},
56+
],
57+
};
5958
} else {
60-
this.setState({
61-
checkedInitial: true
62-
});
59+
initialState = {
60+
...initialState,
61+
checkedInitial: true,
62+
};
6363
}
64+
65+
this.state = initialState;
6466
}
6567

6668
updatePreview = ruleCollection => {

0 commit comments

Comments
 (0)