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 { useRouter } from 'next/router'; | |
const Post = ({ post }) => { | |
const router = useRouter(); | |
if (router.isFallback) { | |
return <div>Loading...</div>; | |
} | |
return <div>{...post}</div>; | |
}; |
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
const App = ({ data }) => <p>{data}</p>; | |
export const getStaticProps = async () => ({ props: { data: 'Hello world' } }); |
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
const Page = ({ data }) => <div>{data}</div>; | |
export const getServerSideProps = async () => { | |
const res = await fetch('https://path/to/your/api'); | |
const data = await res.json(); | |
return { props: { data } }; | |
}; | |
export default Page; |
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
function sum(a, b) { | |
return a + b; | |
} | |
sum(3, 5); |
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
function Person(name, dob) { | |
this.name = name; | |
this.dob = dob; | |
} | |
const sherlock = new Person({ | |
name: 'Sherlock Holmes', | |
dob: '01-06-1852'; | |
}); |
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
const http = require('http'); | |
const heapdump = require('heapdump'); | |
function Bigata() { | |
const mem = Array(1000000).join('a'); | |
} | |
const leak = []; | |
const server = http.createServer(function(request, response) { |
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 useSWR from 'swr'; | |
const Post = () => { | |
const { data, error } = useSWR('/api/post/123', fetch); | |
if (error) { | |
return <div>Error loading post!</div>; | |
} | |
if (!data) { |
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 { useRouter } from 'next/router'; | |
const Post = ({ post }) => { | |
const router = useRouter(); | |
if (router.isFallback) { | |
return <div>Loading...</div>; | |
} | |
return <div>{...post}</div>; |
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
const App = ({ data }) => <p>{data}</p>; | |
export const getStaticProps = async () => ({ props: { data: 'Hello world' } }); |
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
const Page = ({ data }) => <div>{data}</div>; | |
export const getServerSideProps = async () => { | |
const res = await fetch('https://path/to/your/api'); | |
const data = await res.json(); | |
return { props: { data } }; | |
}; | |
export default Page; |