Skip to content

Instantly share code, notes, and snippets.

View oluku-project's full-sized avatar

oluku-project

View GitHub Profile
@oluku-project
oluku-project / StateContext.js
Created January 13, 2023 00:13 — 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);