Let's say this is my pages/visitor.tsx
const PageQuery = 'my query';
const Visitor = () => {
return <div>Hello, World!</div>;
};
export default Visitor;
How do I access PageQuery
in _app.tsx
?
It appears that one way to do it is by attaching PageQuery
as a property to the component function, e.g.,
const PageQuery = 'my query';
const Visitor = () => {
return <div>Hello, World!</div>;
};
Visitor.PageQuery = PageQuery;
export default Visitor;
Now inside of _app.tsx
I can access it like so:
const App = ({ Component, pageProps }: AppProps) => {
Component.PageQuery;
}
However, I was wondering if I am just overlooking a canonical way to access exports for every page when it is being loaded.