New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Typescript example and config files #1610
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import * as React from 'react' | ||
import Link from 'next/link' | ||
import MyComponent from '../components/MyComponent' | ||
|
||
export default () => | ||
export default () => | ||
<div> | ||
<h1>Hello world</h1> | ||
<p>Hello there</p> | ||
<MyComponent /> | ||
</div> | ||
<div>Click <Link prefetch href={{ pathname: 'pagewithasync' }}><a>Reactpage</a></Link> </div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react' | ||
import 'isomorphic-fetch' | ||
|
||
interface IPageProps { | ||
stars: number | ||
} | ||
|
||
interface IPageState { | ||
clicked: boolean | ||
} | ||
|
||
export default class extends React.Component<IPageProps, IPageState> { | ||
static async getInitialProps() { | ||
const res = await fetch('https://api.github.com/repos/zeit/next.js'); | ||
const data = await res.json(); | ||
return { stars: data.stargazers_count } | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe some space after these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import` React from 'react' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes please blank line after every function, class, member, etc. a little |
||
public state: { clicked: false } | ||
private click = () => { | ||
this.setState({ clicked: true }) | ||
} | ||
render() { | ||
return <div onClick={this.click}> | ||
<h1>Next has {this.props.stars} stars</h1> | ||
<span>{this.state.clicked ? 'clicked' : 'please click'}</span> | ||
</div> | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2015", | ||
"jsx": "react", | ||
"allowJs": true | ||
"module": "es2015", | ||
"target": "es2017", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you changing these two fields? this is a pretty significant shift in how the example works. what's wrong with commonjs es6? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the pull request comment |
||
"jsx": "react-native", | ||
"moduleResolution": "node", | ||
"lib": [ | ||
"dom", | ||
"es2017" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See update PR comment above |
||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider camelCasing in the filename?