Next.js Discord

Discord Forum

getStaticProps Not being called

Answered
Black Caiman posted this in #help-forum
Open in Discord
Black CaimanOP
Anyone able to help me on why the getStaticProps function isnt being called?

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
Answered by Ray
move src/app/pages to src/pages
View full answer

22 Replies

Answer
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/pages
the url should be /LandingPage
Black 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

<>
<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 page
src/app/about/page.js will create a route at /about
src/app/home/page.js will create a route at /home
Black CaimanOP
Ok no problem thank you appriciate the help
Black CaimanOP
Will take a look now 🙂