-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent _app.js to be wrapped with default wrapper
Fix #232
- Loading branch information
1 parent
07e012d
commit fd32cac
Showing
4 changed files
with
38 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
import React from 'react'; | ||
import App, {AppInitialProps} from 'next/app'; | ||
import React, {FC} from 'react'; | ||
import {AppProps} from 'next/app'; | ||
import {wrapper} from '../components/store'; | ||
|
||
class WrappedApp extends App<AppInitialProps> { | ||
public render() { | ||
const {Component, pageProps} = this.props; | ||
return <Component {...pageProps} />; | ||
} | ||
} | ||
const WrappedApp: FC<AppProps> = ({Component, pageProps}) => <Component {...pageProps} />; | ||
|
||
export default wrapper.withRedux(WrappedApp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
import React, {Component} from 'react'; | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
import {NextPageContext} from 'next'; | ||
import {connect} from 'react-redux'; | ||
import {State} from '../components/reducer'; | ||
|
||
class ErrorPage extends Component<State> { | ||
public static getInitialProps = ({store, pathname}: NextPageContext) => { | ||
console.log('2. Page.getInitialProps uses the store to dispatch things'); | ||
store.dispatch({type: 'PAGE', payload: 'was set in error page ' + pathname}); | ||
return {}; | ||
}; | ||
|
||
render() { | ||
const {page} = this.props; | ||
return ( | ||
<> | ||
<p> | ||
This is an error page, it also has access to store: <code>{page}</code> | ||
</p> | ||
<nav> | ||
<Link href="/"> | ||
<a>Navigate to index</a> | ||
</Link> | ||
</nav> | ||
</> | ||
); | ||
} | ||
} | ||
const ErrorPage = ({page}: any) => ( | ||
<> | ||
<p>This is an error page, {page}.</p> | ||
<nav> | ||
<Link href="/"> | ||
<a>Navigate to index</a> | ||
</Link> | ||
</nav> | ||
</> | ||
); | ||
|
||
export default connect((state: State) => state)(ErrorPage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters