Created
March 17, 2021 09:15
-
-
Save 4t4nner/d1631585aa25738723cf9889d80cb34f to your computer and use it in GitHub Desktop.
getServerSideProps vs getServerSideProps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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