Day 25 Learning In Public

Day 25: Explored the power of React Query and utilized Tanstack to optimize data fetching and state management in React applications. Leveraging Tanstack's robust features, I achieved seamless integration and efficient caching, enhancing performance and scalability. This newfound knowledge equips me to build dynamic and responsive web applications with ease. Excited to implement React Query and Tanstack in future projects for streamlined data management. ????

import React from 'react';
import { useQuery } from 'react-query';
import axios from 'axios';

const fetchData = async () => {
  const response = await axios.get('https://api.example.com/data');
  return response.data;
};

const MyComponent = () => {
  const { data, isLoading, isError } = useQuery('myData', fetchData);

  if (isLoading) {
    return <div>Loading...</div>;
  }

  if (isError) {
    return <div>Error fetching data</div>;
  }

  return (
    <div>
      <h1>Data from API:</h1>
      <ul>
        {data.map((item) => (
          <li key={item.id}>{item.name}</li>
        ))}
      </ul>
    </div>
  );
};

export default MyComponent;
        

Thanks for the mention, Pratik! Keep going :)

回复

要查看或添加评论,请登录

Pratik Kumar Jaiswal的更多文章

  • Day 23 :Learning In Public

    Day 23 :Learning In Public

    "Unlocking React's Potential: A Deep Dive into the Callback Hook" Mastered the Callback Hook in React today, a powerful…

    1 条评论
  • Day #17 of Learning in Public

    Day #17 of Learning in Public

    In today's project, I unveiled "Marvel Assemble," a dynamic carousel webpage born from HTML, CSS, and JavaScript…

  • DAY #16 of Learning In Public

    DAY #16 of Learning In Public

    Today's creative Endeavor resulted in : A tranquil meditation page crafted with HTML, CSS, and JavaScript. The soothing…

  • DAY #14 OF LEARNING IN PUBLIC

    DAY #14 OF LEARNING IN PUBLIC

    Affordigo Day 14: Explored the CSS property, a pivotal tool in creating versatile, multi-line layouts within flex…

  • Day #13 of Learning In Public

    Day #13 of Learning In Public

    Day 13: Today's exploration led me to the intriguing realm of the CSS property. Discovering how to modify and animate…

    2 条评论
  • Day 12: Today, I delved into the fundamentals of setting up a project.

    Day 12: Today, I delved into the fundamentals of setting up a project.

    Learning the essentials of project structuring, media queries, and responsive design principles has been pivotal. It's…

    2 条评论
  • Save your preloader spinner

    Save your preloader spinner

    codepen link provided below Loader Spinner Follow me Pratik Kumar Jaiswal for more!!! ?? ??#html #css #javascript…

  • Day #10 of Learning In Public

    Day #10 of Learning In Public

    Day 10: Diving into the world of Sass, I harnessed the versatility of , , and properties to create dynamic layouts…

  • Day #9 of Learning in Public.

    Day #9 of Learning in Public.

    A productive day exploring the power of in CSS for layering elements and mastering linear hover effects. These skills…

    1 条评论
  • Day #8 of Learning in Public

    Day #8 of Learning in Public

    Today I learned how to add form and do custom animations as per your choice. Used focus and placeholders in #sass.

社区洞察

其他会员也浏览了