![SurveyJS Logo](https://cdn-b.libhunt.com/images/promo-campaign-images/000/000/030/main.png?1674177924)
-
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
We’ll be looking at a new way to fetch data in React projects in this post. This is a hook built by Vercel, called SWR used for remote data fetching with other features, such as caching, pagination, error handling, auto revalidation, mutation and so on. We’ll be building a Random Store App, using SWR hook to get data from FakeStore API.
We’ll be looking at a new way to fetch data in React projects in this post. This is a hook built by Vercel, called SWR used for remote data fetching with other features, such as caching, pagination, error handling, auto revalidation, mutation and so on. We’ll be building a Random Store App, using SWR hook to get data from FakeStore API.
//Products.js import React from "react"; import axios from "axios"; import useSWR from "swr"; function Products({ count, setCount }) { const address = `https://fakestoreapi.com/products?limit=${count}`; const fetcher = async (url) => await axios.get(url).then((res) => res.data); const { data, error, mutate } = useSWR(address, fetcher, { revalidateIfStale: false, revalidateOnFocus: false, revalidateOnReconnect: false, }); //check error and display corresponding UI if (error) return ( 404 Loading failed... ); //check loading and display corresponding UI if (!data) return ( Loading... ); //create loadMore function const LoadMore = () => { setCount(count + 4); mutate(); }; return ( ///check and display Items LoadMore()}>Load More ); } export default Products;