Skip to content
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

Add useEffect and state to conditionally render footer width/logo #1640

Merged
merged 1 commit into from
Sep 20, 2021

Conversation

LizBaker
Copy link
Contributor

this is a solution, not sure if it's the solution. because it's an SSR issue i wasn't sure of a solution that doesn't involve the developer icon flashing in the footer (but you would have to be scrolled to the bottom and refresh to see it), same with the footer width/icon in the details view (scroll to the bottom and refresh to see)

@LizBaker LizBaker linked an issue Sep 15, 2021 that may be closed by this pull request
2 tasks
@gatsby-cloud
Copy link

gatsby-cloud bot commented Sep 15, 2021

Gatsby Cloud Build Report

developer-website-feature/o11y-packs

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 3m

@jpvajda
Copy link
Contributor

jpvajda commented Sep 15, 2021

I think this ok for GA, and we can look improving it post GA, or waiting until we move to a stand alone Gastby site for I/O which should resolve it I believe.

Copy link
Contributor

@zstix zstix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments.

Overall, while it's not ideal, this is a totally acceptable approach. If we decide to break this site out into it's own stand-alone site then this will not be an issue.

Thanks!!

const [logo, setLogo] = useState(developerLogo);

useEffect(() => {
if (window.location.pathname.includes('instant-observability')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also want to check if window exists so that this doesn't yell at us at build time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe window is always available in useEffect because it only runs after the render and not server side, but we could put a check in there for extra safety!

if (window.location.pathname === '/instant-observability/') {
setSidebarWidth(300);
} else setSidebarWidth(0);
}, [children]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, do we need to add children to the dependency array? This might cause unnecessary calls to this function (whenever anything inside this component changes, this will get called).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this is in the layout it won't fire the effect again (it didn't seem) when switching to the details view since the layout doesn't change. using the children of the layout to determine if it fires was the only way i found to re-trigger it. very open to other solutions though! i just haven't found them 😭

@aswanson-nr aswanson-nr merged commit cc8154c into feature/o11y-packs Sep 20, 2021
@aswanson-nr aswanson-nr deleted the liz/footer-fix branch September 20, 2021 18:29
@nr-opensource-bot
Copy link
Contributor

🎉 This PR is included in version 1.57.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Footer length and icon not loading correctly
5 participants