Skip to content

Instantly share code, notes, and snippets.

View shivam-jha2712's full-sized avatar
🐲
Learning to create something new

Shivam Jha shivam-jha2712

🐲
Learning to create something new
View GitHub Profile
@shivam-jha2712
shivam-jha2712 / StateContext.js
Created September 10, 2022 21:05 — 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);