next.js
f6faf575 - Remove unnecessary indirections around dispatch-related methods (#77423)

Commit
277 days ago
Remove unnecessary indirections around dispatch-related methods (#77423) Best to review commit by commit. The App Router's state lives outside of React, so we don't need to pass the dispatch method around via props/context. We can import it directly into each module that needs it. We have to be a bit clever and assign the dispatch method to a global variable on initialization. This is more complicated than it should be because of a known issue that requires us to decode Flight streams during the render phase. Ideally, we would store the action queue and dispatch method entirely outside of React and pass the state into React as a prop using `root.render`; conceptually, this is how we're modeling it despite the weird implementation details. (We were already using this approach in several places, so it's not new to this PR; I'm just explaining it here for context.) The first commit moves dispatch to a global. The rest of the PR cleans up indirections that can be removed by importing and calling the dispatch method directly.
Author
Parents
Loading