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

[README] Named components and remove 'import react' #506

Merged
merged 2 commits into from Oct 15, 2020
Merged

[README] Named components and remove 'import react' #506

merged 2 commits into from Oct 15, 2020

Conversation

matamatanot
Copy link
Contributor

@matamatanot matamatanot commented Oct 3, 2020

Description of Change(s):

Generally, Next.js recommend the use of named components.

vercel/next.js#17200

https://github.com/vercel/next.js/blob/f8aeaa479ecaaccd4807db42e8df256aa813b194/packages/next/build/babel/plugins/no-anonymous-default-export.ts#L41

Anonymous arrow functions cause Fast Refresh to not preserve local component state.


import React from 'react'; isn't necessary.

vercel/next.js#16603

@matamatanot matamatanot changed the title [README] Named components [README] Named components and remove 'import react' Oct 3, 2020
@matamatanot
Copy link
Contributor Author

How about App Container Deprecated?

In versions prior to v9.0.4 the <Container> component was used in ./pages/_app.js to handle scrolling to hashes.
This handling has been moved up the tree so the <Container> component is no longer needed in your custom <App>!

https://github.com/garmeeh/next-seo/blob/master/README.md#default-seo-configuration

import App, { Container } from 'next/app';
import React from 'react';
import { DefaultSeo } from 'next-seo';

// import your default seo configuration
import SEO from '../next-seo.config';

export default class MyApp extends App {
  render() {
    const { Component, pageProps } = this.props;
    return (
      <Container>
        <DefaultSeo
          openGraph={{
            type: 'website',
            locale: 'en_IE',
            url: 'https://www.url.ie/',
            site_name: 'SiteName',
          }}
          twitter={{
            handle: '@handle',
            site: '@site',
            cardType: 'summary_large_image',
          }}
        />
        <Component {...pageProps} />
      </Container>
    );
  }
}

@garmeeh
Copy link
Owner

garmeeh commented Oct 15, 2020

@matamatanot yeah that example is a little outdated now that I look at it 😅 A pull request to update this to a functional component would be brilliant!

Copy link
Owner

@garmeeh garmeeh left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@garmeeh
Copy link
Owner

garmeeh commented Oct 15, 2020

@all-contributors add @matamatanot doc

@allcontributors
Copy link
Contributor

@garmeeh

I've put up a pull request to add @matamatanot! 🎉

@garmeeh garmeeh merged commit 90710cc into garmeeh:master Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants