-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix(banner-notification): type check error on docs template #6557
Conversation
the boolean passed from docs template to banner notification component has an issue when the variable passed is null. The interface of the banner props has shouldShow declared as boolean or undefined. To prevent each component to check against null to boolean, the check is made internally inside the banner component and shouldShow is declared as boolean or null or undefined.
Gatsby Cloud Build Reportethereum-org-website-dev 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 19m PerformanceLighthouse report
|
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.
Hey @Mousticke thanks for catching this issue. I don't think the problem is in the BannerNotification
component.
BannerNotification is a UI dumb component, it is agnostic of the consumers logic or problems. The problem is on the consumer side, the consumer (template/docs.tsx
in this case) should send the correct value (a boolean) to the component.
// template/docs.tsx
const isPageIncomplete = !!mdx.frontmatter.incomplete // force it to be a boolean
// now we are always sending a boolean to the component
<BannerNotification shouldShow={isPageIncomplete}>
So, if you agree, we should revert these changes and fix it in the docs.tsx
template.
@pettinarip It was my first attempt to do something like this const isPageIncomplete = !!mdx.frontmatter.incomplete // force it to be a boolean Here was my thought : If you do not agree, let's revert and fix it in |
Thanks for sharing your thought @Mousticke. The problem with checking |
@pettinarip Understood and It makes sense. |
isPageIncomplete variable is truthy or falsy but the banner notification component accept a boolean props. So we convert truthy or falsy to true or false Refs: ethereum#6392
Thanks to you, for your comprehension and the time you put into this 💪🏼 |
the component should not check against truthy or falsy value on shouldShow props Refs: ethereum#9362
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.
Thanks @Mousticke 🚀
Description
The boolean passed from docs template to banner notification component
has an issue when the variable passed is null. The interface of the
banner props has shouldShow declared as boolean or undefined. To prevent
each component to check against null to boolean, the check is made
internally inside the banner component and shouldShow is declared as
boolean or null or undefined.
Related Issue
Related to : #6392