rsnext/test/integration/getserversideprops/pages/catchall/[...path].js
JJ Kasper c9d9f1131c
Remove unstable_ prefix from new methods (#10723)
* Rename getServerProps to getServerSideProps

* Remove unstable_ prefix from new methods

* Add error when legacy methods are detected

* Add legacy methods for babel transform

* Add unstable_getServerSideProps also

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Update types import

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-27 11:57:39 -06:00

34 lines
806 B
JavaScript

import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
// eslint-disable-next-line camelcase
export async function getServerSideProps({ params }) {
return {
props: {
world: 'world',
params: params || {},
time: new Date().getTime(),
random: Math.random(),
},
}
}
export default ({ world, time, params, random }) => {
return (
<>
<p>hello: {world}</p>
<span>time: {time}</span>
<div id="random">{random}</div>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/">
<a id="home">to home</a>
</Link>
<br />
<Link href="/another">
<a id="another">to another</a>
</Link>
</>
)
}