getStaticProps doesn't get called
Unanswered
Alaska pollock posted this in #help-forum
Alaska pollockOP
I try to implement getStaticProps into my page, but somehow the function doesn't get called.
I have the following setup:
page.tsx:
Why doens't get getStaticProps called?
I have the following setup:
page.tsx:
import Image from "next/image";
import styles from "./page.module.css";
import { FiPhone } from "react-icons/fi";
import { MdOutlineLocationOn } from "react-icons/Md";
import { getMenu } from "../lib/menu";
interface Menu {
hello: string;
}
export interface Props {
menu: Menu;
}
export default function Home(props: Props) {
console.log(props.menu);
return (
<main className={styles.main}>
<section className={styles.header}>
</section>
<section className={styles.menu}>
<h2>Speisekarte</h2>
</section>
</main>
);
}
export async function getStaticProps() {
console.log("GetStaticProps");
const menu = getMenu();
return {
props: {
menu,
},
};
}Why doens't get getStaticProps called?
3 Replies
@Alaska pollock I try to implement getStaticProps into my page, but somehow the function doesn't get called.
I have the following setup:
page.tsx:
jsx
import Image from "next/image";
import styles from "./page.module.css";
import { FiPhone } from "react-icons/fi";
import { MdOutlineLocationOn } from "react-icons/Md";
import { getMenu } from "../lib/menu";
interface Menu {
hello: string;
}
export interface Props {
menu: Menu;
}
export default function Home(props: Props) {
console.log(props.menu);
return (
<main className={styles.main}>
<section className={styles.header}>
</section>
<section className={styles.menu}>
<h2>Speisekarte</h2>
</section>
</main>
);
}
export async function getStaticProps() {
console.log("GetStaticProps");
const menu = getMenu();
return {
props: {
menu,
},
};
}
Why doens't get getStaticProps called?
in app dir, you no longer need
getStaticProps, and you can do all the fetching in the min function now: https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#static-site-generation-getstaticprops@riský in app dir, you no longer need `getStaticProps`, and you can do all the fetching in the min function now: <https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#static-site-generation-getstaticprops>
Alaska pollockOP
Thanks, that sovel my problem! How can I still use add client side code to that page, to shor something like the current daste on this Statically rendered page?
Make a function that is
"use client" and import it into the server component