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

Warning: viewport meta tags should not be used in _document.js's <Head>. #4

Open
leon-dunamu opened this issue Apr 19, 2021 · 1 comment

Comments

@leon-dunamu
Copy link
Collaborator

next/Headimport하여 _document.js에 넣으니 위와같은 오류 발생

/* _document.js */

class MyDocument extends Document
// ...
  render() {
      <Html {...htmlAttrs}>
        <Head>
         {/* below meta tag line !! */}
          <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
          />
        </Head>
        <body {...bodyAttrs}>
          <Main />
          <NextScript />
        </body>
      </Html>
  }
// ...

모바일 화면에서 유저가 확대하지 못하게 하기위한 meta tag

@leon-dunamu
Copy link
Collaborator Author

_document.js가 아닌 _app.jsHead를 삽입하면 해결!

Nextjs 문서 참고

/* _app.js */
import Head from 'next/head';

const App = ({ Component, pageProps, router: { pathname } }: AppType) => {
  return (
    <>
      <Head>
        <meta
          name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
        />
      </Head>
      <OuterContainer>
        <Header pathname={pathname} />
        <Component {...pageProps} />
      </OuterContainer>
    </>
  );
};

export default App;

@leon-dunamu leon-dunamu mentioned this issue Apr 20, 2021
Merged
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

No branches or pull requests

1 participant