Skip to content

Instantly share code, notes, and snippets.

View sudip004's full-sized avatar

Sudip Basak sudip004

View GitHub Profile
@sudip004
sudip004 / StateContext.js
Created September 9, 2022 12:55 — 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);