Currently, I am in the process of learning nextjs as a beginner.
Through the utilization of the getStaticProps function, I have come to understand that data fetching occurs only once at build time and the values remain static thereafter.
Despite this, I have observed a scenario where the props change whenever the page is refreshed. Here is an example:
const TestPage = ({ number }) => {
return (
<div>
<h1>Return Number</h1>
<span>{number}</span>
</div>
);
};
export const getStaticProps = () => {
return {
props: {
number: Math.random(),
},
};
};
export default TestPage;
The issue seems to be with the output of the Math.random() function not being consistent each time it's invoked.