Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

added _app.js and _document.js and set up getInitialProps #106

Closed

Conversation

KevinDanikowski
Copy link

@KevinDanikowski KevinDanikowski commented Nov 22, 2019

_app.js, _document.js, and getInitialProps have been set up.

Notes have been added to each of those items about what to put in them.

Further, the global header has been changed to PageTitle to be more representative of what it is. The items origionally in global header were moved to _document.js

Fixes #127
Fixes #3

@amclin
Copy link
Owner

amclin commented Nov 22, 2019

Can you split this to multiple PRs for multiple features? It will make it easier to review and bring in changes incrementally

.eslintrc.json Outdated Show resolved Hide resolved
@KevinDanikowski
Copy link
Author

Can you split this to multiple PRs for multiple features? It will make it easier to review and bring in changes incrementally

I can move the _app.js into a separate commit, but all the rest of the changes are associated with either adding _document.js or making the global header a title only. Either way those changes go together. What would you prefer I do?

@amclin
Copy link
Owner

amclin commented Nov 25, 2019

Please follow the commit message expectations - (npm install should be including husky to enforce this on commit). For details, check the contribution guidelines

@KevinDanikowski
Copy link
Author

@amclin sorry I didn't see that before, I will adjust accordingly.

@@ -89,6 +89,7 @@
],
"coveragePathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/default/src/pages/_document.jsx",
Copy link
Author

Choose a reason for hiding this comment

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

removed since it is basic default code with only changes to head, but items in the head are tested in separate component tests.

Copy link
Owner

Choose a reason for hiding this comment

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

It shouldn't be ignored from code coverage

[
"next/babel",
{
"preset-env": { "targets": { "node": "current" } }
Copy link
Author

Choose a reason for hiding this comment

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

this was required to be able to extend a class in document.js

Copy link
Owner

Choose a reason for hiding this comment

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

Fixes #127?

import PropTypes from 'prop-types'
import Head from 'next/head'

const PageTitle = ({ title }) => {
Copy link
Author

Choose a reason for hiding this comment

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

change to title since that is the one thing that we may want to change from components outside document.js

Copy link
Owner

Choose a reason for hiding this comment

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

Is the key really necessary? I don't think eslint-react nor react is going to issue a warning here since it's wrapped in the element

@KevinDanikowski
Copy link
Author

To note, I have made the requested changes.

Copy link
Owner

@amclin amclin left a comment

Choose a reason for hiding this comment

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

Please see the review comments.

Can you also merge the latest master into your branch to resolve the merge conflicts.

Thanks!

"plugins": ["react"],
"rules": {
"react/prop-types": ["error"],
"react/jsx-props-no-spreading": ["warn"],
Copy link
Owner

Choose a reason for hiding this comment

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

Can you revert these rule changes and use comments to exclude single lines please?

@@ -89,6 +89,7 @@
],
"coveragePathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/default/src/pages/_document.jsx",
Copy link
Owner

Choose a reason for hiding this comment

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

It shouldn't be ignored from code coverage

@@ -62,6 +62,7 @@
"collectCoverageFrom": ["**/*.{js,jsx,ts,tsx}"],
"coveragePathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/src/pages/_document.jsx",
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't be ignored - not a good example to set. If you look at the client-internal repo forked from this, I believe I have an example of testing the _app.jsx or _document.jsx

[
"next/babel",
{
"preset-env": { "targets": { "node": "current" } }
Copy link
Owner

Choose a reason for hiding this comment

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

Fixes #127?

@@ -19,6 +19,9 @@
},
"plugins": ["react"],
"rules": {
"react/prop-types": ["error"]
"react/prop-types": ["error"],
Copy link
Owner

Choose a reason for hiding this comment

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

Please revert these and use comments for single-line excludes

import PropTypes from 'prop-types'
import Head from 'next/head'

const PageTitle = ({ title }) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Is the key really necessary? I don't think eslint-react nor react is going to issue a warning here since it's wrapped in the element

*/
import React from 'react'
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Flavicon from '../components/molecules/Favicon'
Copy link
Owner

Choose a reason for hiding this comment

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

Flavicon? Is that a typo?

@KevinDanikowski
Copy link
Author

see PR #166

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.

Add getInitialProps example .babelrc's babel/preset-env conflicts with next/babel.
2 participants