• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

106
Views
React js best way for live preview table

I wonder what is the best way for making table in react, live update. I'm doing it with setInterval, but I would like to know is there a way for making it without sending unnecessary requests to the server.

  const [data, setData] = useState([]);
  useEffect(() => {
    const interval = setInterval(() => {
      async function getData() {
        const result = await axios(
          "/api/data/?format=json"
        );
        setData(result.data);
        setLoadingData(false);
      }
      if (loadingData) {
        // if the result is not ready so you make the axios call
        getData();
      };
    }, 3000);
    return () => clearInterval(interval);
  }, []);
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use web sockets to emit an event from the server to the connected clients. But, this involves change in the server code. I'm not sure if you have access to server code.

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error