How to pass location
prop to MDXGlobalComponents?
#28898
Unanswered
iammatthias
asked this question in
Help
Replies: 2 comments
-
tbd if this works in build, but for now I'm parsing it out of |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for pointing us in that direction @iammatthias. That lead me to the import { useLocation } from '@reach/router';
export const MyComponentInAnMDXPage = (props) => {
const location = useLocation();
return <div>Current path: location.pathname</div>;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I've been puzzling over this for a couple of days now.
Based on the docs (https://www.gatsbyjs.com/docs/location-data-from-props) I am calling
location
in myindex.js
file.That is being passed to my
layout
component.My goal is to pass is down to a component that lists different pages based on category. Only problem is,
location
returns undefined when called from the component.How can I get
location
to pass throughMDXRenderer
orThemeProvider
in order to be accessed in a component that is called via MDX?Beta Was this translation helpful? Give feedback.
All reactions