Skip to content

Instantly share code, notes, and snippets.

@soberkin
soberkin / StateContext.js
Created October 15, 2022 08:10 — forked from adrianhajdin/StateContext.js
Build and Deploy a Modern Full Stack ECommerce Application with Stripe
import React, { createContext, useContext, useState, useEffect } from 'react';
import { toast } from 'react-hot-toast';
const Context = createContext();
export const StateContext = ({ children }) => {
const getLocalStorage = (name) => {
if (typeof window !== 'undefined') {
const storage = localStorage.getItem(name);