Commit d6f9de5
committed
Always trigger componentWillUnmount in StrictMode (#26842)
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.
Before submitting a pull request, please make sure the following is
done:
1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
10. If you haven't already, complete the CLA.
Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->
## Summary
<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->
In StrictMode, React currently only triggers `componentWillUnmount` if
`componentDidMount` is defined. This would miss detecting issues like
initializing resources in constructor or componentWillMount, for
example:
```
class Component {
constructor() {
this._subscriptions = new Subscriptions();
}
componentWillUnmount() {
this._subscriptions.reset();
}
}
```
The PR makes `componentWillUnmount` always run in StrictMode.
## How did you test this change?
<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
If you leave this empty, your PR will very likely be closed.
-->
`yarn test ci`
DiffTrain build for [8110222](8110222)1 parent 9908c7d commit d6f9de5
File tree
19 files changed
+1658
-1706
lines changed- compiled/facebook-www
19 files changed
+1658
-1706
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
| 644 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
12590 | 12590 | | |
12591 | 12591 | | |
12592 | 12592 | | |
12593 | | - | |
12594 | | - | |
12595 | | - | |
12596 | | - | |
12597 | | - | |
| 12593 | + | |
| 12594 | + | |
12598 | 12595 | | |
12599 | | - | |
| 12596 | + | |
| 12597 | + | |
12600 | 12598 | | |
12601 | 12599 | | |
12602 | 12600 | | |
| |||
12658 | 12656 | | |
12659 | 12657 | | |
12660 | 12658 | | |
12661 | | - | |
12662 | | - | |
12663 | | - | |
12664 | | - | |
12665 | | - | |
| 12659 | + | |
| 12660 | + | |
12666 | 12661 | | |
12667 | | - | |
| 12662 | + | |
| 12663 | + | |
12668 | 12664 | | |
12669 | 12665 | | |
12670 | 12666 | | |
| |||
12710 | 12706 | | |
12711 | 12707 | | |
12712 | 12708 | | |
12713 | | - | |
12714 | | - | |
12715 | | - | |
12716 | | - | |
12717 | | - | |
| 12709 | + | |
| 12710 | + | |
12718 | 12711 | | |
12719 | | - | |
| 12712 | + | |
| 12713 | + | |
12720 | 12714 | | |
12721 | 12715 | | |
12722 | 12716 | | |
12723 | 12717 | | |
12724 | 12718 | | |
12725 | | - | |
12726 | | - | |
12727 | | - | |
12728 | | - | |
12729 | | - | |
| 12719 | + | |
| 12720 | + | |
12730 | 12721 | | |
12731 | | - | |
| 12722 | + | |
| 12723 | + | |
12732 | 12724 | | |
12733 | 12725 | | |
12734 | 12726 | | |
| |||
23789 | 23781 | | |
23790 | 23782 | | |
23791 | 23783 | | |
23792 | | - | |
23793 | | - | |
23794 | | - | |
23795 | | - | |
| 23784 | + | |
| 23785 | + | |
| 23786 | + | |
| 23787 | + | |
| 23788 | + | |
| 23789 | + | |
23796 | 23790 | | |
23797 | 23791 | | |
23798 | 23792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
12322 | 12322 | | |
12323 | 12323 | | |
12324 | 12324 | | |
12325 | | - | |
12326 | | - | |
12327 | | - | |
12328 | | - | |
12329 | | - | |
| 12325 | + | |
| 12326 | + | |
12330 | 12327 | | |
12331 | | - | |
| 12328 | + | |
| 12329 | + | |
12332 | 12330 | | |
12333 | 12331 | | |
12334 | 12332 | | |
| |||
12383 | 12381 | | |
12384 | 12382 | | |
12385 | 12383 | | |
12386 | | - | |
12387 | | - | |
12388 | | - | |
12389 | | - | |
12390 | | - | |
| 12384 | + | |
| 12385 | + | |
12391 | 12386 | | |
12392 | | - | |
| 12387 | + | |
| 12388 | + | |
12393 | 12389 | | |
12394 | 12390 | | |
12395 | 12391 | | |
| |||
12435 | 12431 | | |
12436 | 12432 | | |
12437 | 12433 | | |
12438 | | - | |
12439 | | - | |
12440 | | - | |
12441 | | - | |
12442 | | - | |
| 12434 | + | |
| 12435 | + | |
12443 | 12436 | | |
12444 | | - | |
| 12437 | + | |
| 12438 | + | |
12445 | 12439 | | |
12446 | 12440 | | |
12447 | 12441 | | |
12448 | 12442 | | |
12449 | 12443 | | |
12450 | | - | |
12451 | | - | |
12452 | | - | |
12453 | | - | |
12454 | | - | |
| 12444 | + | |
| 12445 | + | |
12455 | 12446 | | |
12456 | | - | |
| 12447 | + | |
| 12448 | + | |
12457 | 12449 | | |
12458 | 12450 | | |
12459 | 12451 | | |
| |||
23454 | 23446 | | |
23455 | 23447 | | |
23456 | 23448 | | |
23457 | | - | |
23458 | | - | |
23459 | | - | |
23460 | | - | |
| 23449 | + | |
| 23450 | + | |
| 23451 | + | |
| 23452 | + | |
| 23453 | + | |
| 23454 | + | |
23461 | 23455 | | |
23462 | 23456 | | |
23463 | 23457 | | |
| |||
0 commit comments