File tree Expand file tree Collapse file tree 9 files changed +122
-0
lines changed Expand file tree Collapse file tree 9 files changed +122
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "presets" : [
3+ " next/babel"
4+ ],
5+ "plugins" : [
6+ " transform-flow-strip-types"
7+ ]
8+ }
Original file line number Diff line number Diff line change 1+ [ignore]
2+
3+ [include]
4+
5+ [libs]
6+
7+ [options]
Original file line number Diff line number Diff line change 1+ # Example app with [ Flow] ( https://flowtype.org/ )
2+
3+ ## How to use
4+
5+ Download the example [ or clone the repo] ( https://github.com/zeit/next.js ) :
6+
7+ ``` bash
8+ curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-styled-components
9+ cd with-flow
10+ ```
11+
12+ Install it and run:
13+
14+ ``` bash
15+ npm install
16+ npm run dev
17+ ```
18+
19+ Deploy it to the cloud with [ now] ( https://zeit.co/now ) ([ download] ( https://zeit.co/download ) )
20+
21+ ``` bash
22+ now
23+ ```
24+
25+ ## The idea behind the example
26+
27+ This example shows how you can use Flow, with the transform-flow-strip-types babel plugin stripping flow type annotations from your output code.
28+
29+ ![ with-flow] ( with-flow.gif )
Original file line number Diff line number Diff line change 1+ // @flow
2+
3+ import type { Element } from 'React'
4+ import Link from 'next/link'
5+ import Head from 'next/head'
6+
7+ type Props = {
8+ children ?: Element < any > ,
9+ title ?: string
10+ }
11+
12+ export default ( { children, title = 'This is the default title' } : Props ) => (
13+ < div >
14+ < Head >
15+ < title > { title } </ title >
16+ < meta charSet = 'utf-8' />
17+ < meta name = 'viewport' content = 'initial-scale=1.0, width=device-width' />
18+ </ Head >
19+ < header >
20+ < nav >
21+ < Link href = '/' > < a > Home</ a > </ Link > |
22+ < Link href = '/about' > < a > About</ a > </ Link > |
23+ < Link href = '/contact' > < a > Contact</ a > </ Link >
24+ </ nav >
25+ </ header >
26+ { children }
27+ < footer >
28+ I`m here to stay
29+ </ footer >
30+ </ div >
31+ )
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " with-flow" ,
3+ "version" : " 1.0.0" ,
4+ "license" : " MIT" ,
5+ "author" : " Jag Reehal" ,
6+ "scripts" : {
7+ "dev" : " next" ,
8+ "build" : " next build" ,
9+ "flow" : " flow; test $? -eq 0 -o $? -eq 2" ,
10+ "start" : " next start"
11+ },
12+ "dependencies" : {
13+ "next" : " ^2.0.0-beta"
14+ },
15+ "devDependencies" : {
16+ "babel-eslint" : " ^7.1.1" ,
17+ "babel-plugin-transform-flow-strip-types" : " ^6.21.0" ,
18+ "flow-bin" : " ^0.37.4"
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ // @flow
2+
3+ import Layout from '../components/layout'
4+
5+ export default ( ) => (
6+ < Layout title = 'About us' >
7+ < div > About us</ div >
8+ </ Layout >
9+ )
Original file line number Diff line number Diff line change 1+ // @flow
2+
3+ import Layout from '../components/layout'
4+
5+ export default ( ) => (
6+ < Layout title = 'Contact us' >
7+ < div > Contact</ div >
8+ </ Layout >
9+ )
Original file line number Diff line number Diff line change 1+ // @flow
2+
3+ import Layout from '../components/layout'
4+
5+ export default ( ) => (
6+ < Layout >
7+ < div > Hello World.</ div >
8+ </ Layout >
9+ )
You can’t perform that action at this time.
0 commit comments