Where is the empty object coming from and why is it there?
Unanswered
Ring-necked Duck posted this in #help-forum
Ring-necked DuckOP
I came upon this bug/unexpected behaviour in a project so I made a repro as a sanity check
I don't understand why the props object being printed is empty when I clearly do set some properties inside getStaticProps.
If you want to test the code, here it is (i put it in a file called
I don't understand why the props object being printed is empty when I clearly do set some properties inside getStaticProps.
If you want to test the code, here it is (i put it in a file called
[id].tsx
in a fresh next project):import { GetStaticProps } from "next";
interface Props {
testing: true;
}
export default (props: Props) => {
console.log({ props });
return <div>Skill issue</div>;
};
export const getStaticProps: GetStaticProps<Props> = () => {
return { props: { testing: true } };
};
export const getStaticPaths = async () => {
const paths: { params: { id: string } }[] = [];
console.log(paths);
return { paths, fallback: true };
};
1 Reply
Ring-necked DuckOP
Seems like next.js yeets an empty object if you have fallback: true, nice to know