Skip to content

Instantly share code, notes, and snippets.

View johan44co's full-sized avatar
🧮
-_-_-_-_-

Johan johan44co

🧮
-_-_-_-_-
View GitHub Profile
@johan44co
johan44co / react-context-api.ts
Created May 6, 2023 19:15
Using React Context API with TypeScript can make managing state across components a breeze! Check out this code snippet to see how it's done 👀 #React #TypeScript #WebDevelopment
import React, { createContext, useContext, useState } from 'react';
// define the shape of your context value
interface AppContextValue {
count: number;
incrementCount: () => void;
}
// create the context with initial values
const AppContext = createContext<AppContextValue>({