Skip to content
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

Merged
merged 3 commits into from
Jan 31, 2019

Conversation

resir014
Copy link
Contributor

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 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>
Copy link
Contributor Author

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. 🤔

@resir014
Copy link
Contributor Author

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>
Copy link
Member

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?

Copy link
Contributor Author

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 Links. 😅

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright 👍

@timneutkens timneutkens merged commit 8fdb133 into vercel:canary Jan 31, 2019
resir014 added a commit to resir014/next.js that referenced this pull request Feb 10, 2019
As per discussion in vercel#6165, I removed the `passHref` in `Link` as
they're unnecessary.
timneutkens pushed a commit that referenced this pull request Feb 10, 2019
…6233)

As per discussion in #6165, I removed the `passHref` in `Link` as
they're unnecessary.
@lock lock bot locked as resolved and limited conversation to collaborators Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants