-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the Config context #11742
Improve the Config context #11742
Conversation
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
Size Change: -87 B (-0.01%) Total Size: 867 kB ℹ️ View Unchanged
|
} else { | ||
return JSON.parse(serialised) as Config; | ||
config = JSON.parse(serialised) as Config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the keen beans amongs you: consider using valibot to parse this?
renderingTarget: Extract<RenderingTarget, 'Web'>; | ||
darkModeAvailable: boolean; | ||
updateLogoAdPartnerSwitch: boolean; | ||
assetOrigin: AssetOrigin; | ||
} | ||
| { | ||
editionId: EditionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a rule in the sand for our context use that Context should be considered global, static, and immutable - Does this violate that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not:
- The immutability is now guaranteed by TS’s
Readonly<T>
Utility type; - The edition is static for a given request, you need a different request to get a different edition;
- The edition is global, no component is allowed to have a different edition than the one used in the request.
Note that Edition was previously a candidate for using Context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
What does this change?
ReadOnly
so it’s not inadvertently mutatededitionId
to the configLatestLinks
and squash potential bugsWhy?
This pattern, introduced in #8704, has been very useful. This addressed initial concerns from @georgeblahblah, @ioanna0 and myself about redundant data in the HTML. Adding the edition can help reduce deeply drilled props, and reduce bugs, such as in
CardAge