In developer mode worked great. Later in CMD, I sent "npm run build. Got error...
info - Checking validity of types
info - Creating an optimized production build
info - Compiled successfully
> Build optimization failed: found pages without a React Component as default export in
pages/js/TimeClock
pages/js/ChangePage
I tried to fix it. Nothing on the internet helped. Here are my files:
index.js
import Head from 'next/head'
import Time from './js/TimeClock.page';
import { ChangePage0, ChangePage1, ChangePage2 } from './js/ChangePage.page';
export default function Home() {
...
}
TimeClock.page.js
import ReactDOM from 'react-dom'
export function tick()
{
const site = (
<div>
<span className="time">
{new Date().toLocaleTimeString()}
</span>
</div>
);
ReactDOM.render(site, document.getElementById('time'));
}
setInterval(tick, 1000);
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
module.exports = {
pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'], nextConfig
}
Not sure to understrand what you're trying to do with the setIinterval on a component but you probably need to export default instead of a naming export.
In TimeClock.page.js
function Tick() {
...
}
export default Tick;