-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
[with-typescript] Improved intial props examples, added example detail #6165
[with-typescript] Improved intial props examples, added example detail #6165
Conversation
If a TS file has no JSX syntax, we don't need the `.tsx` extension
I've just thought of a way to improve the initial props page by adding an example for a list/detail page structure. To do that, I've created a separate `/detail` page, and a mock API which calls data from the array we made on the previous PR. A ListDetail component is created as an example for displaying detail. Page structure is also cleaned up. Should I go ahead and add an example on how to style with styled-jsx + its TS declarations? I might decide to do it within this week anyway.
if (errors) { | ||
return ( | ||
<Layout title={`Error | Next.js + TypeScript Example`}> | ||
<p><span style={{ color: 'red' }}>Error:</span> {errors}</p> |
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.
Not sure if I should show an example to extend the default Error component or not. 🤔
Just synced this PR with upstream. |
import IDataObject from '../interfaces' | ||
|
||
type Props = { | ||
data: IDataObject, | ||
} | ||
|
||
const ListItem: React.FunctionComponent<Props> = ({ data }) => ( | ||
<React.Fragment>{data.id}:{data.name}</React.Fragment> | ||
<Link href={`/detail?id=${data.id}`} passHref> |
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.
passHref is not required on Link tags, or is it when using typescript?
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.
It should be fine without passHref
, I'm just used to putting that in for Link
s. 😅
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.
Looks alright 👍
As per discussion in vercel#6165, I removed the `passHref` in `Link` as they're unnecessary.
I've just thought of a way to improve the initial props page by adding
an example for a list/detail page structure. To do that, I've created a
separate
/detail
page, and a mock API which calls data from the arraywe made on the previous PR.
A ListDetail component is created as an example for displaying detail.
Page structure is also cleaned up. Should I go ahead and add an example
on how to style with styled-jsx + its TS declarations? I might decide to
do it within this week anyway.