-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wb1812.0.fixrenderstate] Make sure RenderState.Root is an internal c…
…oncept only (#2387) ## Summary: This addresses an issue where `useRenderState` would return `RenderState.Root` during initial render to components nested inside our `RenderStateRoot` component, when they should only ever see `Initial` or `Standard`. I suspect this was happening due to hook execution order and render order. React component render functions are executed from the inside out, and I suspect that because of this, the initial call to `useRenderState` is using the default context value, because the root component hasn't rendered it's value yet - a general flaw in hook-based context access. However, for everything but `RenderStateRoot` and `InitialFallback` components, code doesn't need to know if it's the root render or not. It's an easier API if they just always see `Initial` or `Standard`. This change makes that happen. The only components that need to know are those that need to render the actual context, and our consumers don't need to do that. This addresses an issue where the `useUniqueId` hook and it's initial render fallback version would throw an error on initial render. It's a precursor PR to unblock folks while we work on replacing our unique ID stuff with `useId`. Issue: WB-1812 ## Test plan: `yarn test` `yarn typecheck` I also checked our Wonder Blocks consumers to verify that they don't care about the "root" render state (as they shouldn't). ## Release Info: This is a major release of Core because we are changing the `RenderState` enum to remove a value, and changing the behavior of the `useRenderState` hook. In real terms, consumers should be unaffected, but changing exports like this should be a major release so following protocol. Author: somewhatabstract Reviewers: jandrade, nedredmond Required Reviewers: Approved By: jandrade Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️ dependabot, ✅ gerald Pull Request URL: #2387
- Loading branch information
1 parent
0955be7
commit f4abd57
Showing
8 changed files
with
92 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-core": major | ||
--- | ||
|
||
- Remove `RenderState.Root` from exported enum | ||
- Change `useRenderState` to only return `RenderState.Initial` or `RenderState.Standard` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters