react/scripts
Andrew Clark cc24d0ea56
Invariant that throws when committing wrong tree (#15517)
If React finishes rendering a tree, delays committing it (e.g.
Suspense), then subsequently starts over or renders a new tree, the
pending tree is no longer valid. That's because rendering a new work-in
progress mutates the old one in place.

The current structure of the work loop makes this hard to reason about
because, although `renderRoot` and `commitRoot` are separate functions,
they can't be interleaved. If they are interleaved by accident, it
either results in inconsistent render output or invariant violations
that are hard to debug.

This commit adds an invariant that throws if the new tree is the same as
the old one. This won't prevent all bugs of this class, but it should
catch the most common kind.

To implement the invariant, I store the finished tree on a field on the
root. We already had a field for this, but it was only being used for
the unstable `createBatch` feature.

A more rigorous way to address this type of problem could be to unify
`renderRoot` and `commitRoot` into a single function, so that it's
harder to accidentally interleave the two phases. I plan to do something
like this in a follow-up.
2019-05-13 16:15:50 -07:00
..
babel Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
bench Update Readme (#14176) 2018-11-12 16:25:32 +00:00
circleci Stop tracking bundle sizes (#15404) 2019-04-12 13:33:27 -07:00
error-codes Invariant that throws when committing wrong tree (#15517) 2019-05-13 16:15:50 -07:00
eslint Refactor ESLint configuration to enable better IDE integration (#13914) 2018-11-08 17:56:35 +00:00
eslint-rules Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
flow Event API: use capture for all event listeners using experimental responder system (#15526) 2019-04-30 11:40:45 +01:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Replace old Fiber Scheduler with new one (#15387) 2019-04-11 19:15:34 -07:00
perf-counters Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
prettier Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
print-warnings Fix babel-preset-fbjs configure link in comment (#13666) 2018-10-21 12:23:24 -05:00
release Fixed typo (#14943) 2019-02-24 09:50:23 -08:00
rollup Fork ReactSharedInternals for UMD builds (#15617) 2019-05-10 13:51:39 -07:00
shared Replace old Fiber Scheduler with new one (#15387) 2019-04-11 19:15:34 -07:00
tasks Switch to @sizebot token (#13622) 2018-09-11 21:06:44 +01:00
authors AUTHORS 2013-09-09 23:42:54 -07:00