Skip to content

Commit 33c05a9

Browse files
Yarn update, TOC generator
1 parent 29fa507 commit 33c05a9

File tree

13 files changed

+15873
-10450
lines changed

13 files changed

+15873
-10450
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
node-version: '16.x'
2121

2222
- id: yarn-cache-dir-path
23-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
23+
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
2424

2525
- uses: actions/cache@v3
2626
with:
@@ -31,7 +31,7 @@ jobs:
3131
restore-keys: |
3232
${{ runner.os }}-yarn-
3333
34-
- run: yarn install --prefer-offline
34+
- run: yarn install
3535

3636
- run: DEBUG=eslint:cli-engine yarn lint:all
3737

.yarn/releases/yarn-3.4.1.cjs

Lines changed: 873 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
yarn-path ".yarn/releases/yarn-3.4.1.cjs"

.yarnrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
yarnPath: .yarn/releases/yarn-3.4.1.cjs
2+
13
nodeLinker: node-modules
4+
5+
pnpMode: loose

README.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Redux Wrapper for Next.js <!-- omit in toc -->
1+
# Redux Wrapper for Next.js
22

33
[![npm version](https://badge.fury.io/js/next-redux-wrapper.svg)](https://www.npmjs.com/package/next-redux-wrapper)
44
![Build status](https://travis-ci.org/kirill-konshin/next-redux-wrapper.svg?branch=master)
@@ -12,20 +12,23 @@ A library that brings Next.js and Redux together.
1212
>
1313
> With that said, if you are using `app` folder, I suggest to keep Redux in client components (`"use client"`), and keep server-side state outside of Redux.
1414
15+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
16+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
17+
1518
- [Motivation](#motivation)
1619
- [Installation](#installation)
1720
- [Usage](#usage)
18-
- [Store](#step-1-create-a-store)
19-
- [App](#step-2-add-store-to-your-app)
20-
- [Pages](#step-3-add-hydration-to-pages)
21-
- [getStaticProps](#getstaticprops)
22-
- [getServerSideProps](#getserversideprops)
23-
- [Page.getInitialProps](#pagegetinitialprops)
24-
- [App.getInitialProps](#appgetinitialprops)
21+
- [Step 1. Create a store](#step-1-create-a-store)
22+
- [Step 2. Add store to your App](#step-2-add-store-to-your-app)
23+
- [Step 3. Add hydration to Pages](#step-3-add-hydration-to-pages)
24+
- [getStaticProps](#getstaticprops)
25+
- [getServerSideProps](#getserversideprops)
26+
- [`Page.getInitialProps`](#pagegetinitialprops)
27+
- [`App.getInitialProps`](#appgetinitialprops)
2528
- [State reconciliation during hydration](#state-reconciliation-during-hydration)
2629
- [Configuration](#configuration)
2730
- [How it works](#how-it-works)
28-
- [Tips and Tricks](#tips-and-tricks)
31+
- [Tips and Tricks](#tips-and-tricks)
2932
- [Redux Toolkit](#redux-toolkit)
3033
- [Server and Client state separation](#server-and-client-state-separation)
3134
- [Document](#document)
@@ -34,13 +37,15 @@ A library that brings Next.js and Redux together.
3437
- [Custom serialization and deserialization](#custom-serialization-and-deserialization)
3538
- [Usage with Redux Saga](#usage-with-redux-saga)
3639
- [Usage with Redux Persist](#usage-with-redux-persist)
37-
- [Usage with Old Class Based Components](#usage-with-old-class-based-components)
40+
- [Usage with old class-based components](#usage-with-old-class-based-components)
3841
- [Upgrade from 8.x to 9.x](#upgrade-from-8x-to-9x)
3942
- [Upgrade from 6.x to 7.x](#upgrade-from-6x-to-7x)
4043
- [Upgrade from 5.x to 6.x](#upgrade-from-5x-to-6x)
4144
- [Upgrade from 1.x to 2.x](#upgrade-from-1x-to-2x)
4245
- [Resources](#resources)
4346

47+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
48+
4449
# Motivation
4550

4651
Setting up Redux for static single page apps is rather simple: a single Redux store has to be created that is provided to all pages.
@@ -297,7 +302,7 @@ All pages still can have all standard data lifecycle methods, with one common pi
297302

298303
# State reconciliation during hydration
299304

300-
Each time when the user opens a page containing the `useHydration` hook, the actions performed on server will be dispatched on client as well. This may happen during initial page load and during regular page navigation. Your reducer must merge it with existing client state properly.
305+
Each time when the user opens a page containing the `useHydration` hook, the actions performed on server will be dispatched on client as well. This may happen during initial page load and during regular page navigation. Your reducer must merge it with existing client state properly. This means "toggle" actions are not supported, each action has to analyze what's in the state and do things properly.
301306

302307
Best way is to use [server and client state separation](#server-and-client-state-separation).
303308

@@ -581,7 +586,7 @@ export const wrapper = createWrapper(makeStore, {
581586
});
582587
```
583588

584-
### Using `getServerSideProps` or `getStaticProps`
589+
#### Using `getServerSideProps` or `getStaticProps`
585590

586591
If you don't want to opt-out of automatic pre-rendering in your Next.js app, you can manage server-called sagas on a per page basis like [the official Next.js "with Redux Saga" example](https://github.com/vercel/next.js/tree/canary/examples/with-redux-saga) does. If you do go with this option, please ensure that you await any and all sagas within any [Next.js page methods](https://nextjs.org/docs/basic-features/data-fetching). If you miss it on one of pages you'll end up with inconsistent state being sent to client.
587592

@@ -597,7 +602,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({re
597602
});
598603
```
599604

600-
### Using `App.getInitialProps`
605+
#### Using `App.getInitialProps`
601606

602607
:warning: Not Recommended! :warning:
603608

@@ -751,7 +756,7 @@ export default ({fromServer, fromClient, setClientState}) => {
751756

752757
## Usage with old class-based components
753758

754-
### App
759+
#### App
755760

756761
If you're still using old class-based
757762

@@ -794,7 +799,7 @@ export default withStore(MyApp);
794799

795800
Next.js provides [generic `getInitialProps`](https://github.com/vercel/next.js/blob/canary/packages/next/src/pages/_app.tsx#L39) which will be picked up by wrapper, so you **must not extend `App`** as you'll be opted out of Automatic Static Optimization: https://err.sh/next.js/opt-out-auto-static-optimization. Just export a regular Functional Component or extend `React.Component` as in the example above.
796801

797-
### Pages
802+
#### Pages
798803

799804
```js
800805
function DefaultLoading() {
@@ -832,7 +837,7 @@ export default connect(state => state)(
832837
);
833838
```
834839

835-
## Upgrade from 8.x to 9.x
840+
# Upgrade from 8.x to 9.x
836841

837842
1. `HYDRATE` action has been removed, all actions are replayed as-is
838843

@@ -860,7 +865,7 @@ export default connect(state => state)(
860865

861866
8. `const makeStore = (context) => {...}` is now `const makeStore = ({context, reduxWrapperMiddleware})`, you must add `reduxWrapperMiddleware` to your store
862867

863-
## Upgrade from 6.x to 7.x
868+
# Upgrade from 6.x to 7.x
864869

865870
1. Signature of `createWrapper` has changed: instead of `createWrapper<State>` you should use `createWrapper<Store<State>>`, all types will be automatically inferred from `Store`.
866871

@@ -872,7 +877,7 @@ export default connect(state => state)(
872877

873878
5. **window.NEXT_REDUX_WRAPPER_STORE** has been removed as it was causing [issues with hot reloading](https://github.com/kirill-konshin/next-redux-wrapper/pull/324)
874879

875-
## Upgrade from 5.x to 6.x
880+
# Upgrade from 5.x to 6.x
876881

877882
Major change in the way how things are wrapped in version 6.
878883

@@ -888,7 +893,7 @@ Major change in the way how things are wrapped in version 6.
888893

889894
6. `WrappedAppProps` was renamed to `WrapperProps`.
890895

891-
## Upgrade from 1.x to 2.x
896+
# Upgrade from 1.x to 2.x
892897

893898
If your project was using Next.js 5 and Next Redux Wrapper 1.x these instructions will help you to upgrade to 2.x.
894899

@@ -944,9 +949,9 @@ If your project was using Next.js 5 and Next Redux Wrapper 1.x these instruction
944949

945950
That's it. Your project should now work the same as before.
946951

947-
## Resources
952+
# Resources
948953

949954
- [next-redux-saga](https://github.com/bmealhouse/next-redux-saga)
950955
- [How to use with Redux and Redux Saga](https://www.robinwieruch.de/nextjs-redux-saga/)
951-
- Redux Saga Example: https://gist.github.com/pesakitan22/94b4984140ba0f2c9e52c5289a7d833e.
956+
- [Redux Saga Example](https://gist.github.com/pesakitan22/94b4984140ba0f2c9e52c5289a7d833e)
952957
- [next-redux-cookie-wrapper](https://github.com/bjoluc/next-redux-cookie-wrapper)

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.0.0",
2+
"version": "1.0.0",
33
"useWorkspaces": true,
44
"npmClient": "yarn"
55
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "7.0.0",
55
"description": "Redux wrapper for Next.js",
66
"scripts": {
7+
"doc": "doctoc --maxlevel 3 --notitle README.md",
78
"prepare": "husky install",
89
"clean": "lerna run clean && lerna clean --yes && rimraf node_modules",
910
"start": "yarn build && yarn start:all",
@@ -18,6 +19,7 @@
1819
"lint:staged": "lint-staged --debug"
1920
},
2021
"devDependencies": {
22+
"doctoc": "2.2.1",
2123
"eslint": "8.33.0",
2224
"eslint-config-ringcentral-typescript": "7.0.3",
2325
"husky": "7.0.4",
@@ -40,7 +42,7 @@
4042
},
4143
"homepage": "https://github.com/kirill-konshin/next-redux-wrapper",
4244
"license": "MIT",
43-
"packageManager": "yarn@3.0.2",
45+
"packageManager": "yarn@3.4.1",
4446
"resolutions": {
4547
"@types/react": "18.0.27",
4648
"typescript": "4.5.5"

packages/demo-page/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"version": "7.0.0",
55
"description": "Demo of redux wrapper for Next.js",
66
"scripts": {
7+
"wait": "wait-on -v ../wrapper/es6/index.js",
78
"clean": "rimraf .next coverage",
8-
"test": "playwright test",
9-
"start": "next --port=4000"
9+
"test": "yarn wait && playwright test",
10+
"start": "yarn wait && next --port=4000"
1011
},
1112
"dependencies": {
12-
"jsondiffpatch": "0.4.1",
1313
"next-redux-wrapper": "*",
1414
"react": "18.2.0",
1515
"react-dom": "18.2.0",
@@ -27,7 +27,8 @@
2727
"next-redux-wrapper-configs": "*",
2828
"playwright": "1.30.0",
2929
"rimraf": "3.0.2",
30-
"typescript": "4.9.5"
30+
"typescript": "4.9.5",
31+
"wait-on": "7.0.1"
3132
},
3233
"author": "Kirill Konshin",
3334
"repository": {

packages/demo-redux-toolkit/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"version": "7.0.0",
44
"private": true,
55
"scripts": {
6+
"wait": "wait-on -v ../wrapper/es6/index.js",
67
"clean": "rimraf .next coverage",
7-
"test": "playwright test",
8-
"start": "next --port=6060"
8+
"test": "yarn wait && playwright test",
9+
"start": "yarn wait && next --port=6060"
910
},
1011
"dependencies": {
1112
"@reduxjs/toolkit": "1.8.6",
@@ -21,7 +22,8 @@
2122
"@types/react": "18.0.27",
2223
"@types/react-dom": "18.0.10",
2324
"next": "13.1.6",
24-
"playwright": "1.30.0"
25+
"playwright": "1.30.0",
26+
"wait-on": "7.0.1"
2527
},
2628
"license": "MIT"
2729
}

packages/demo-saga-page/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"version": "7.0.0",
55
"description": "Demo of redux wrapper for Next.js",
66
"scripts": {
7+
"wait": "wait-on -v ../wrapper/es6/index.js",
78
"clean": "rimraf .next coverage",
8-
"test": "playwright test",
9-
"start": "next --port=5050"
9+
"test": "yarn wait && playwright test",
10+
"start": "yarn wait && next --port=5050"
1011
},
1112
"dependencies": {
1213
"jsondiffpatch": "0.4.1",
@@ -28,7 +29,8 @@
2829
"next-redux-wrapper-configs": "*",
2930
"playwright": "1.30.0",
3031
"rimraf": "3.0.2",
31-
"typescript": "4.9.5"
32+
"typescript": "4.9.5",
33+
"wait-on": "7.0.1"
3234
},
3335
"author": "Kirill Konshin",
3436
"repository": {

0 commit comments

Comments
 (0)