Hi, I came here since I didnt find in the docs something specific for this case, in Next.js we have an _app.js component which injects a component from it’s props
function MyApp({ Component, pageProps }) {
return <Layout>
<Component {...pageProps} />
</Layout>
}
since I want to use all my codebase in rescript is there any way to use a ~ named argument with Capitalized letter and call it as a component?
Thanks
Maybe not exactly what you are asking for, but the ReScript NextJS starter project shows how this might be done:
// This type is based on the getInitialProps return value.
// If you are using getServerSideProps or getStaticProps, you probably
// will never need this
// See https://nextjs.org/docs/advanced-features/custom-app
type pageProps
module PageComponent = {
type t = React.component<pageProps>
}
type props = {
@as("Component")
component: PageComponent.t,
pageProps: pageProps,
}
// We are not using `@react.component` since we will never
// use <App/> within our ReScript code.
// It's only used within `pages/_app.js`
let default = (props: props): React.element => {
1 Like
oh nice example, even though IDK why one would need a router if next is filesystem based.