This repository was archived by the owner on Nov 27, 2022. It is now read-only.
Commit 4f1982c
fix: Only update state if mounted. (#1081)
### Motivation
This component always logs error in the console when testing.
```
Warning: Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the Pager component.
Warning: Can't call forceUpdate on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the Pager component.
```
PR adds some mounted checks.
### Test plan
As long as tests pass and dont log.
Co-authored-by: Miles Johnson <miles.johnson@coinbase.com>1 parent 350f783 commit 4f1982c
1 file changed
+14
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
| |||
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| 237 | + | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| 244 | + | |
| 245 | + | |
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
245 | 251 | | |
246 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
247 | 256 | | |
248 | 257 | | |
249 | 258 | | |
| |||
531 | 540 | | |
532 | 541 | | |
533 | 542 | | |
534 | | - | |
| 543 | + | |
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
| |||
577 | 586 | | |
578 | 587 | | |
579 | 588 | | |
580 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
581 | 592 | | |
582 | 593 | | |
583 | 594 | | |
| |||
0 commit comments