swr Questions
3
Solved
I'm using react-query v3.13 to fetch data from API.
What I want to do is to fetch API regularly from a certain point (for example, when clicking the start button), not from the time of calling useQ...
Petard asked 23/3, 2021 at 3:50
3
Solved
I am currently building a web app with next.js, which requires real-time updates across devices, for example, if someone joins a group this needs to be instantly shown for all existing members of t...
3
I make project using nextjs 13.4.7 and already install swr in 3 PC but I got the same error:
Attempted import error: 'swr' does not contain a default export (imported as 'useSWR').
error TypeError:...
2
Solved
I am using SWR to fetch data to populate a table with. I am using the following code:
const { data: items, error } = useSWR(fetchAllItems.name, fetchAllItems)
The fetcher function looks like this
...
3
I have a React application which uses SWR + Axios for data fetching (https://swr.vercel.app/docs/data-fetching). The issue is that my custom hook which uses useSwr is fetching all data initially wh...
2
Solved
I was asked a question regarding SWRs "loading" state:
How do you create a loading state from SWR between different URL fetches?
Their docs make it appear straight forward:
const { dat...
1
Solved
I am now trying to make a crud functionality with file upload on my project. I have done the creation part and it's all working fine since I implemented that with new FormData() by appending the fi...
1
Solved
I'm struggling mocking the SWR fetch api call with MSW.
You can reproduce the issue with this repo: https://github.com/charitha95/msw-test
Error that I'm facing when using MSW:
Error: connect ECON...
1
I am using SWR in a React.js application and I find myself needing to display the loading status of a request.
I created a helper function that extracts the loading status from an SWRResponse simil...
Barbie asked 22/9, 2021 at 20:18
3
I have a component in React in need of an array of users. I'm able to fetch one single user at a time with useUwr like so:
export function Hello(id: number) {
const { data } = useSWR('/api/user/{i...
1
Solved
I am switching certain CRUD functionality that I used to provide with a token, but now I am using SWR and I don't know how to convert it.
I used this hook for GET methods but for others, I don't kn...
Adelleadelpho asked 7/6, 2022 at 10:10
3
I'm using the SWR
In my code I am using the junction of both as follows
const vehiclesStates = useSelector(({ vehiclesStates: state }) => state); // REDUX
const response = useFetch("/vehicl...
Bowdlerize asked 18/12, 2020 at 21:50
1
So, I'm planning on doing a Facebook clone to add to my portfolio, and I want to use, react-Next.js, node.js, express.js, typeORM and postgresSQL ( everything in typescript ), but i have a big issu...
2
Solved
The useSWR hook from swr works everywhere if I explicitly enter the fetcher.
const { data } = useSWR("http://...", fetcher);
However, if I used swr global configuration as shown below, t...
Tautologism asked 22/10, 2021 at 17:56
0
I'm trying to fetch the data i get to an API route in my Next.js app but it doesn't work.
Here's my code on my API route where i get the data:
import nc from "next-connect";
const jobHan...
Aleurone asked 2/1, 2022 at 16:7
1
Solved
currently i am using SWR to data fetching, i trying to use Mutation feature of SWR to refetch the new data but this occurred a problem when i am calling mutate() by key was added new query params.
...
2
Solved
In my Next.js app, the component is getting re-rendered when I change the browser tab and then get back to the tab in which the app is already opened. e.g. app is open tab 1 and when I switch to ta...
1
Solved
I have decided to attempt to move majority of my API function to SWR as it simply allows me to do so much more!
Problem
However, I am having a huge issue where I cannot figure out how to properly p...
Bucephalus asked 24/10, 2021 at 5:15
4
Solved
I am using useSWR to fetch data and then with the data, I want to get a total by using reduce. If I console.log the value out it works fine but as soon as I try to set the state with the value I ge...
2
const fetcher = (url: string) => fetch(url).then((r) => r.json());
const { data, error } = useSWR(
"https://some.com/api",
fetcher,
);
is there any way to add data in a useSt...
Allen asked 27/9, 2021 at 11:9
2
Solved
I have a unit test which includes rendering a component that uses useSWR to fetch data. But the data is not ready before the expect() is being called so the test fails.
test("StyleOptionDetail...
Sapota asked 10/9, 2021 at 13:25
1
when user type some text in input search data-testid = 'loading' must be removed, now console return Unable to find an element by: [data-testid="loading"]
can some one sugesstion me to wr...
Directory asked 13/6, 2021 at 13:27
2
Solved
I am looking for a pattern that would allow me to better the UX for my users. I have a REST server running behind CloudFront being consumed from a plain React application on the frontend.
I'll simp...
1
Solved
I'm trying to figure out if there's a way to abstract the data fetching hooks I've created, with Typescripts generics, for my React app. Unfortunately my understanding of Typescript isn't as good a...
Maravedi asked 31/3, 2021 at 10:29
1
Solved
I've written a custom hook that uses SWR to retrieve data from my API whilst setting the 'Authentication' header for the request.
The hook is working fine for all successful requests but I want to ...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.