Skip to content

Commit d0a241a

Browse files
committed
Early return if we are not clientside
1 parent 7aaa305 commit d0a241a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

utils/context/AppContext.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ export const AppProvider = ({ children }) => {
1111

1212
useEffect(() => {
1313
// Check if we are client-side before we access the localStorage
14-
if (process.browser) {
15-
let cartData = localStorage.getItem('woocommerce-cart');
16-
cartData = null !== cartData ? JSON.parse(cartData) : '';
17-
setCart(cartData);
14+
if (!process.browser) {
15+
return;
1816
}
17+
let cartData = localStorage.getItem('woocommerce-cart');
18+
cartData = null !== cartData ? JSON.parse(cartData) : '';
19+
setCart(cartData);
1920
}, []);
2021

2122
return (

0 commit comments

Comments
 (0)