Reputation: 141
I am new to react and I am currently trying out some basic example. I have just created a linked index page and an about page. I then created a custom App component which should display everything in the container, instead it is just showing the home/about linked buttons and 'Hello next.js' text (it is not showing ('On every Page'). See page layout below
On every page *** this is not showing Home page button | About page button Hello next.js
Can anyone see any errors? I have tried searching but I still can not see where I am going wrong
// _app.js
import App, {Container} from 'next/app';
//define the custome App - a class which extends the
default App
class myApp extends App {
return() {
//compent will be the page content
// e.g. index or about
const {Component, pageProps} = this.props;
return (
//container contains page content
<Container>
{/* Content which will be shared */}
<p>On every Page</p>
{/* Component is page e.g. index or about
*/}
<Component {...pageProd}/>
</Container>
);
}
}
export default myApp;
//index.js
import Link from 'next/link'
// Pass this content as 'props' to child components
const Index = props => (
<div>
<Link href="/index">
<button>Home page</button>
</Link>
<Link href="/about">
<button>About page</button>
</Link>
<p>Hello Next.js</p>
</div>
)
export default Index
// about.js
import Link from 'next/link'
// Pass this content as 'props' tp child components
const About = props => (
<div>
<Link href="/">
<button>Home page</button>
</Link>
<Link href="/about">
<button>About page</button>
</Link>
<p>Hello Next.js</p>
</div>
)
export default About
Upvotes: 0
Views: 5165
Reputation: 185
I had a similar problem, My issue was with cache , try this
rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm run build:tailwind && npm run dev
Upvotes: 1