提交 c090a57e 编写于 作者: T Tomek 提交者: Tim Neutkens

update with-flow example (#4835)

Changes:
* updated packages
* moved the content of `layout` to `_app.js` and created simple `Page` component
* replaced `import * as React` because it is not necessary to import everything
* moved `next.js.flow` to `flow-typed` as it is default directory for library definitions
* updated the gif
上级 d1fbcfe5
......@@ -4,6 +4,5 @@
[include]
[libs]
types/
[options]
// @flow
import React, { type Node } from 'react'
import Head from 'next/head'
type Props = {
children: Node,
title?: string
}
export default ({ children, title = 'This is the default title' }: Props) => (
<section>
<Head>
<title>{title}</title>
</Head>
{children}
</section>
)
// @flow
import * as React from 'react'
import Link from 'next/link'
import Head from 'next/head'
type Props = {
children?: React.Node,
title?: string
}
export default ({children, title = 'This is the default title'}: Props) => (
<div>
<Head>
<title>{title}</title>
<meta charSet='utf-8' />
<meta name='viewport' content='initial-scale=1.0, width=device-width' />
</Head>
<header>
<nav>
<Link href='/'><a>Home</a></Link>|
<Link href='/about'><a>About</a></Link>|
<Link href='/contact'><a>Contact</a></Link>
</nav>
</header>
{children}
<footer>
I`m here to stay
</footer>
</div>
)
/* @flow */
// @flow
declare module "next" {
declare type NextApp = {
......
......@@ -15,8 +15,8 @@
"react-dom": "^16.0.0"
},
"devDependencies": {
"babel-eslint": "8.2.1",
"babel-eslint": "8.2.6",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"flow-bin": "0.64.0"
"flow-bin": "0.77.0"
}
}
import App, {Container} from 'next/app'
import Link from 'next/link'
import React from 'react'
export default class MyApp extends App {
static async getInitialProps ({ Component, router, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return {pageProps}
}
render () {
const {Component, pageProps} = this.props
return (
<Container>
<header>
<nav>
<Link href='/'><a>Home</a></Link>|
<Link href='/about'><a>About</a></Link>|
<Link href='/contact'><a>Contact</a></Link>
</nav>
</header>
<Component {...pageProps} />
<footer>
I`m here to stay
</footer>
</Container>
)
}
}
// @flow
import * as React from 'react'
import Layout from '../components/layout'
import React from 'react'
import Page from '../components/Page'
export default () => (
<Layout title='About us'>
<Page title='About us'>
<div>About us</div>
</Layout>
</Page>
)
// @flow
import * as React from 'react'
import Layout from '../components/layout'
import React from 'react'
import Page from '../components/Page'
export default () => (
<Layout title='Contact us'>
<Page title='Contact us'>
<div>Contact</div>
</Layout>
</Page>
)
// @flow
import * as React from 'react'
import Layout from '../components/layout'
import React from 'react'
import Page from '../components/Page'
export default () => (
<Layout>
<div>Hello World.</div>
</Layout>
<Page>
<div>Hello World</div>
</Page>
)
examples/with-flow/with-flow.gif

264.2 KB | W: | H:

examples/with-flow/with-flow.gif

988.9 KB | W: | H:

examples/with-flow/with-flow.gif
examples/with-flow/with-flow.gif
examples/with-flow/with-flow.gif
examples/with-flow/with-flow.gif
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册