Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4t4nner/d1631585aa25738723cf9889d80cb34f to your computer and use it in GitHub Desktop.
Save 4t4nner/d1631585aa25738723cf9889d80cb34f to your computer and use it in GitHub Desktop.
getServerSideProps vs getServerSideProps
import React, {FunctionComponent} from "react";
import MainLayout from "../components/layouts/MainLayout";
import {IComponentProps} from "../components/declarations";
import { GetStaticProps, GetServerSideProps } from 'next'
import {randomInt} from "crypto";
export default function Login({children, rand}: IComponentProps) {
console.log(arguments,rand);
return (
<>
<MainLayout title={'Авторизация'}>
<p>login</p>
<p>random: {rand}</p>
</MainLayout>
</>
)
}
export const getStaticProps: GetStaticProps = async (context) => {
debugger;
console.log('!!!!!!!!!!getStaticProps - 0!!!!!!!!');
return new Promise<any>(resolve => {
setTimeout(() => {
console.log('!!!!!!!!!!getStaticProps - 1!!!!!!!!');
resolve({
props: {
rand: randomInt(1000)
}
})
},5000)
})
};
// export const getServerSideProps: GetServerSideProps = async (context) => {
// debugger;
// console.log('!!!!!!!!!!getStaticProps - 0!!!!!!!!');
//
// return new Promise<any>(resolve => {
// setTimeout(() => {
// console.log('!!!!!!!!!!getStaticProps - 1!!!!!!!!');
//
// resolve({
// props: {
// rand: randomInt(1000)
// }
// })
// },5000)
// })
// };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment