Questions tagged [swr]

SWR is a React Hooks library for remote data fetching.

The name “SWR” is derived from stale-while-revalidate, a cache invalidation strategy popularized by HTTP RFC 5861. SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.

369 questions
0
votes
1 answer

Optimistic UI (react, swr, immer)

I would love a short code review of "my" implementation of optimistic ui patterns. I'm using SWR, immer and a custom fetch hook to do most of the heavy lifting. However, I'm not really sure if this is indeed the way to do it. Especially when it…
0
votes
1 answer

Next.js SWR accessing data from cache

I have a problem with accessing data from cache. I have my dahboard component. Data fetching here is ok, and i can access it. const Dashboard = ({ code }) => { const { data, error, mutate } = useSWR(['/api/user', code], (url,…
kl_user_333
  • 143
  • 2
  • 9
-1
votes
1 answer

I am getting endlessly API requests using SWR and Axios in nextjs

It is my first time of using SWR. Maybe I am wrongly implementing it. After implementing the SWR wrapper, I continued to get endless and repeated API call to the same endpoint. I saw this when I checked the Network tab of my browser: Here is how I…
-1
votes
1 answer

I am unable to fetch data with SWR in Nextjs

I am trying to use SWR in Next.js for the first time. I am using Axios to make http calls. The Axios make calls to protected API routes and I handled that using interceptor. Here is one of the places where I used the SWR but I am getting undefined…
-1
votes
1 answer

How can useSWR return undefined when fallbackData is specified?

I am using useSWR within a Next.js application to fetch data on the client side to dynamically load data from an external API given a query parameter that specifies the language. However to ensure initial loading of the page, I retrieve data in a…
Raphael
  • 1
  • 1
-1
votes
1 answer

Axios Patch method is overriding the existing data

enter image description here If i decide to update only one field and i leave other fields empty because they already have data that i don't need to update, my axios patch method overrides the existing data with an empty data which is a very bad…
Leyksnal
  • 13
  • 5
-1
votes
1 answer

SWR stuck in loading state. Even after request is completed

I am using SWR to complete a simple API request however after I just finished formatting the API how I wanted SWR is now stuck In it's loading state and I am very confused as to why I have tried a few different things and none have yet to resolve my…
MatDoak
  • 132
  • 5
  • 17
-1
votes
1 answer

Why this code for SWR interval fetching is not working?

I would like to refresh data every 1 second. But this code below is not working. const fetchSupplyInfo = (slice, accounts) => (...args) => { const vSupply = slice.methods.sliceParams().call({ from: accounts[0] }).then((data) => {return…
Stano
  • 9
  • 1
-1
votes
1 answer

Error when trying to fetch an API using SWR (Next.js)

I run successfully the following code from SWR examples page: import useSWR from "swr"; const fetcher = url => fetch(url).then(res => res.json()); export default function App() { const { data, error } = useSWR( …
Luis García
  • 43
  • 1
  • 5
1 2 3
24
25