Skip to content

Commit

Permalink
Update README to remove deprecated Container from next/app dependency (
Browse files Browse the repository at this point in the history
…#155)

* Update README to remove deprecated Container from `next/app`, note for using `Container` NextJS before v9.04
  • Loading branch information
marshallmcdonnell authored and kirill-konshin committed Sep 27, 2019
1 parent b1b3d06 commit 99dd4e6
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here is the minimal setup (`makeStore` and `reducer` usually are located in othe
import React from "react";
import {createStore} from "redux";
import {Provider} from "react-redux";
import App, {Container} from "next/app";
import App from "next/app";
import withRedux from "next-redux-wrapper";

const reducer = (state = {foo: ''}, action) => {
Expand Down Expand Up @@ -78,11 +78,9 @@ class MyApp extends App {
render() {
const {Component, pageProps, store} = this.props;
return (
<Container>
<Provider store={store}>
<Component {...pageProps} />
</Provider>
</Container>
<Provider store={store}>
<Component {...pageProps} />
</Provider>
);
}

Expand All @@ -91,6 +89,22 @@ class MyApp extends App {
export default withRedux(makeStore)(MyApp);
```

> **NOTE**: For versions of NextJS < 9.04, you will need to wrap the `Provider` with `Container` from `next/app`.
> Thus, the import statement will be:
> ```js
> import App, {Container} from "next/app";
> ```
> And wrapping the `Provider` will be:
> ```js
> return (
> <Container>
> <Provider store={store}>
> <Component {...pageProps} />
> </Provider>
> </Container>
> );
> ```
And then actual page components can be simply connected:
```js
Expand Down

0 comments on commit 99dd4e6

Please sign in to comment.