Skip to content

Instantly share code, notes, and snippets.

View NaveenDA's full-sized avatar
🤿
Dive deep into the code

Naveen NaveenDA

🤿
Dive deep into the code
View GitHub Profile
import useSWR from 'swr'
function Profile() {
const { data, error } = useSWR('/api/user', fetcher)
if (error) return <div>failed to load</div>
if (!data) return <div>loading...</div>
return <div>hello {data.name}!</div>
}
import { mutate } from 'swr'
function prefetch () {
mutate('/api/data', fetch('/api/data').then(res => res.json()))
// the second parameter is a Promise
// SWR will use the result when it resolves
}
import React from "react";
import { SWRConfig } from "swr";
const App = () => {
return (
<SWRConfig
value={{
onError: (error, key) => {
if (error.status !== 403 && error.status !== 404) {
// We can send the error to Sentry,
import { QueryClient, QueryClientProvider, useQuery } from 'react-query'
const queryClient = new QueryClient()
export default function App() {
return (
<QueryClientProvider client={queryClient}>
<Example />
</QueryClientProvider>
)
import React,{useState} from "react";
import ReactDOM from "react-dom";
import { QueryClient, QueryClientProvider, useQuery } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
const queryClient = new QueryClient();
export default function App() {
return (
<QueryClientProvider client={queryClient}>
@NaveenDA
NaveenDA / main.js
Last active July 8, 2024 01:02
stem infra template
// ==UserScript==
// @name Stem's Infra Template
// @namespace http://tampermonkey.net/
// @source https://gist.github.com/NaveenDA/64c8ce07461e0c2f9feb6dabd1dcf00a
// @updateURL https://gist.githubusercontent.com/raw/64c8ce07461e0c2f9feb6dabd1dcf00a/main.js
// @downloadURL https://gist.githubusercontent.com/raw/64c8ce07461e0c2f9feb6dabd1dcf00a/main.js
// @version 2024-07-12
// @description try to take over the world!
// @author naveenda
// @match https://web.whatsapp.com/*