Question about giving the layout component information about the page component for per page transitions. #8659
Labels
type: question or discussion
Issue discussing or asking a question about Gatsby
Summary
I spent some time a couple weeks ago figuring out how to get a different page transition for each page (as specified by the page component) and I came up with what seems to me to be a reliable enough solution. It feels hacky though and I'm wondering if there's a better way to do this in gatsby.
I'm using
gatsby-plugin-layout
to create my own layout component that doesn't unmount. I'm then adding default props to my page components with a transition component as a prop. The layout component then checks the props of the page component since it has access to it and it wraps the page component in the specified transition component.example site
example repo
In my page component:
In my layout component:
Relevant information
This seems to work well because the layout component can just check the props of the page component but I have a feeling this is really hacky. Is there a better way for the layout component to know about the page component?
I thought maybe I could use the context api for this but I couldn't get it to actually work.
The text was updated successfully, but these errors were encountered: