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

docs: use function for components in general #33990

Merged
merged 1 commit into from Feb 4, 2022

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Feb 4, 2022

Documentation / Examples

In general all docs use function to ensure it matches up with general recommendations (e.g. React docs).

  • Make sure the linting passes by running yarn lint

@ijjk ijjk merged commit 4812e22 into vercel:canary Feb 4, 2022
@kachkaev
Copy link
Contributor

kachkaev commented Feb 4, 2022

👋 Folks, do you know the reason behind those recommendations? Just wonder if there is any public info on that – I could not find any.

const Home = () => {} is more compatible with TypeScript: const Home: NextPage = () => {}, which makes migration to TS easier.

Also if someone is a newcomer in JS, using arrow functions everywhere is simpler because there’s one less syntax construct to learn. Inline fns are inevitable anyway because they are used in React hooks.

I tried suggesting React folks to switch to const Component = () => {} in new docs, but I haven't heard any arguments against it. Maybe my comment was just lost amongst others: reactjs/react.dev#3308 (comment).

natew pushed a commit to natew/next.js that referenced this pull request Feb 16, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2022
@huozhi huozhi deleted the errors/use-function branch May 11, 2022 22:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants