Skip to content

Instantly share code, notes, and snippets.

View highlander08's full-sized avatar
:octocat:
Codar por Paixão | Aluno | @Rocketseat

Highlander Santos highlander08

:octocat:
Codar por Paixão | Aluno | @Rocketseat
View GitHub Profile
@highlander08
highlander08 / useLocalStorage.ts
Created April 12, 2023 13:18 — forked from fedek6/useLocalStorage.ts
Working useLocalStorage hook for Next.js (no warnings in console)
/* eslint-disable no-console */
/* eslint-disable react-hooks/exhaustive-deps */
import { useState, useEffect } from "react";
export const useLocalStorage = <T>(key: string, initialValue: T) => {
const [storedValue, setStoredValue] = useState<T | undefined>();
const setValue = (value: T) => {
window.localStorage.setItem(key, JSON.stringify(value));
};
@highlander08
highlander08 / context-and-localstorage-using-hooks.js
Created April 12, 2023 13:18 — forked from jimode/context-and-localstorage-using-hooks.js
Providing Context and Local Storage Using Hooks
// Providing Context
// ==================
import React, {useState, useEffect} from "react"
const Context = React.createContext()
function ContextProvider({children}) {
const [allPhotos, setAllPhotos] = useState([])
const [cartItems, setCartItems] = useState([])
@highlander08
highlander08 / App.tsx
Created August 29, 2022 16:32 — forked from joaobibiano/App.tsx
Código da Vídeo sobre React com typescript
import { useState } from "react";
import "./App.css";
type TypographyProps = {
children: React.ReactNode;
size?: "small" | "large";
};
type ParagraphProps = {
color: string;
@highlander08
highlander08 / UserList.tsx
Created July 21, 2022 05:35 — forked from pjchender/UserList.tsx
Recoil Pattern inspired from useContext
import { STATE, useUsers } from '@/state/user';
import { useEffect } from 'react';
const UserList = () => {
// STEP 4: useUser to get data from state and actions
const { users, actions } = useUsers();
const { removeUser, fetchUsers, resetUser } = actions;
useEffect(() => {
// if you want to get the newest users every time, otherwise the cache will be used