Skip to content

Commit 8c69c3d

Browse files
committed
Refactor: Renamed prevState argument to state
The purpose of using an updater function is to get the latest, up-to-date version of the state, which accessing this.state might not give. Using the name prevState for something that might actually be the next upcoming state may lead thinking astray.
1 parent 09175a3 commit 8c69c3d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/pages/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,54 +249,54 @@ class Index extends React.Component {
249249
}
250250

251251
handleNodeStyleChange = (style) => {
252-
this.setPersistentState(prevState => ({
252+
this.setPersistentState(state => ({
253253
defaultNodeAttributes: {
254-
...prevState.defaultNodeAttributes,
254+
...state.defaultNodeAttributes,
255255
style: style,
256256
},
257257
}));
258258
}
259259

260260
handleNodeColorChange = (color) => {
261-
this.setPersistentState(prevState => ({
261+
this.setPersistentState(state => ({
262262
defaultNodeAttributes: {
263-
...prevState.defaultNodeAttributes,
263+
...state.defaultNodeAttributes,
264264
color: color,
265265
},
266266
}));
267267
}
268268

269269
handleNodeFillColorChange = (color) => {
270-
this.setPersistentState(prevState => ({
270+
this.setPersistentState(state => ({
271271
defaultNodeAttributes: {
272-
...prevState.defaultNodeAttributes,
272+
...state.defaultNodeAttributes,
273273
fillcolor: color,
274274
},
275275
}));
276276
}
277277

278278
handleEdgeStyleChange = (style) => {
279-
this.setPersistentState(prevState => ({
279+
this.setPersistentState(state => ({
280280
defaultEdgeAttributes: {
281-
...prevState.defaultEdgeAttributes,
281+
...state.defaultEdgeAttributes,
282282
style: style,
283283
},
284284
}));
285285
}
286286

287287
handleEdgeColorChange = (color) => {
288-
this.setPersistentState(prevState => ({
288+
this.setPersistentState(state => ({
289289
defaultEdgeAttributes: {
290-
...prevState.defaultEdgeAttributes,
290+
...state.defaultEdgeAttributes,
291291
color: color,
292292
},
293293
}));
294294
}
295295

296296
handleEdgeFillColorChange = (color) => {
297-
this.setPersistentState(prevState => ({
297+
this.setPersistentState(state => ({
298298
defaultEdgeAttributes: {
299-
...prevState.defaultEdgeAttributes,
299+
...state.defaultEdgeAttributes,
300300
fillcolor: color,
301301
},
302302
}));

0 commit comments

Comments
 (0)