Skip to content

Instantly share code, notes, and snippets.

View shivam9410-hub's full-sized avatar
🎯
Focusing

Shivam Khantwal shivam9410-hub

🎯
Focusing
View GitHub Profile
@shivam9410-hub
shivam9410-hub / StateContext.js
Created May 18, 2022 16:40 — 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);