Skip to content

Commit e25423c

Browse files
committed
Actually fix next.js error
1 parent 4d7b7d5 commit e25423c

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

examples/nextjs/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"next": "13.1.6",
1414
"react": "18.2.0",
1515
"react-dom": "18.2.0",
16-
"use-shopping-cart": "workspace:^3.1.4"
16+
"use-shopping-cart": "workspace:^3.1.5"
1717
},
1818
"devDependencies": {
1919
"autoprefixer": "^10.4.13",
@@ -22,4 +22,3 @@
2222
"tailwindcss": "^3.2.6"
2323
}
2424
}
25-

examples/nextjs/pages/_app.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ export default function App({ Component, pageProps }) {
1818
// Having this setting means that we will capture shipping address
1919
allowedCountries={['GB']}
2020
// Enables local storage
21-
shouldPersist={false}
21+
shouldPersist={true}
2222
>
2323
<Layout>
2424
<Component {...pageProps} />
2525
</Layout>
2626
</CartProvider>
2727
)
2828
}
29-

pnpm-lock.yaml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

use-shopping-cart/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-shopping-cart",
3-
"version": "3.1.5",
3+
"version": "3.1.6",
44
"description": "Shopping cart state and logic for Stripe",
55
"author": "dayhaysoos",
66
"license": "MIT",

use-shopping-cart/react/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ import { createDispatchHook, createSelectorHook, Provider } from 'react-redux'
1010
import { PersistGate } from 'redux-persist/integration/react'
1111
import { persistStore } from 'redux-persist'
1212

13+
import { isClient } from '../utilities/SSR'
14+
1315
export { actions, filterCart, formatCurrencyString }
1416
export const CartContext = React.createContext(initialState)
1517
export const useSelector = createSelectorHook(CartContext)
1618
export const useDispatch = createDispatchHook(CartContext)
1719

1820
export function CartProvider({ loading = null, children, ...props }) {
21+
if (!isClient) return null
22+
1923
const store = React.useMemo(() => createShoppingCartStore(props), [props])
2024

2125
if (props?.shouldPersist || props.shouldPersist === undefined) {

0 commit comments

Comments
 (0)