yarn add @pago/reactive
Install the plugin:
yarn add @babel/plugin-transform-react-jsx
Then add the .babelrc
configuration file:
{
"presets": ["next/babel"],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"throwIfNamespace": false,
"runtime": "automatic",
"importSource": "@pago/reactive"
}
]
]
}
Because Next.js is controlling the components that are mounted and we don't control the initial mounting ourselves, we need to have a top-level component (either App
or Document
) that is a standard React component instead of a Reactive Component. From there on, all our components can just be Reactive Components.
In this case we decided to implement an ./pages/_app.js
.
function App({ Component, pageProps }) {
return <Component {...pageProps} />;
}
export default App;