Skip to content

Instantly share code, notes, and snippets.

View tigawanna's full-sized avatar

Dennis kinuthia tigawanna

  • Nairobi Kenya
View GitHub Profile
@tigawanna
tigawanna / nextjs-localstorage-hook.md
Created September 3, 2022 08:45
hook to read and write the local storage in NextJs

useLocalStorage the custom hook

strapped this together to help save and retrieve the user-theme and token from the localstorage

was working on a react vite app and had to port it over to Next Js the ported next js app and i very quickly discovered that localStorage worked a little differently n Nextjs and i need it because that's where i was saving my personal access token and theme preferences which lead me down a rabbit hole which resulted in the following custom hook for that

react-query tips and tricks i've found usefull while working with github's graphql api

using select to insert a new value into the response

import React from 'react'
import { useQuery } from 'react-query';
import { GraphQLClient } from 'graphql-request';
import { gql } from 'graphql-tag';