getStaticProps Not being called
Answered
Black Caiman posted this in #help-forum
Black CaimanOP
Anyone able to help me on why the getStaticProps function isnt being called?
This in the directory pages btw
import HeroComponent from "../Components/Hero";
import PopularDestinations from "../Components/PopularDestinations";
import PopularDestinationsData from '../data/PopularDestinationsData';
const LandingPage = ({ popularDestinations }) => {
console.log('Popular Landing' , popularDestinations)
return (
<div>
<HeroComponent />
<PopularDestinations popularDestinations={popularDestinations} />
</div>
);
};
export const getStaticProps = async () => {
const data = PopularDestinationsData;
console.log('Data', data);
return {
props: {
popularDestinations: data,
},
};
};
export default LandingPage;This in the directory pages btw
22 Replies
Black CaimanOP
That still didnt work for me
@Black Caiman That still didnt work for me
what is not working
Black CaimanOP
The getStaticProps isnt being called. I dont see my console log
@Black Caiman The getStaticProps isnt being called. I dont see my console log
how to folder structure and what url are you accessing
Black CaimanOP
The page.js is loaded by default
@Black Caiman Click to see attachment
so what do you expect
Black CaimanOP
you have
LandingPage inside src/pagesthe url should be
/LandingPageBlack CaimanOP
ahhh I forgot about the Routing on NextJS. Ok that actually works.
So how do I make a page /
Like root
Sorry im new to NextJS normally use React haha
I mean for example in React I can have
I assume that doesnt work quite like that in Next
<>
<NavigationBar/> // Global for all pages
<Route route={HomeRoute}>
<Route route={AboutUS}>
</>I assume that doesnt work quite like that in Next
src/app/page.js is your index pagesrc/app/about/page.js will create a route at /aboutsrc/app/home/page.js will create a route at /homeBlack CaimanOP
Ok no problem thank you appriciate the help
Black CaimanOP
Will take a look now 🙂