Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
How to update status of multiple items at once in Nextjs

I have 3 lists of items (users1, user2, users3) displayed as slider items. Each item is an object. An item looks like:

activity_status: "online"
id: "62d0ca6b114db3d"
is_favorite: false
last_login_at: "2022-07-18T02:09:49.458Z"
match_status: null
review_count: 0

I use useQuery to update status for each item in a slider. It's look like:

const {
    data: users1,
    refetch: refetchUsers1,
    isLoading: isLoading1,
  } = useQuery(
    REACT_QUERY_KEYS.USER1,
    async () => {
      setIsLoading(false);
      const res = await getUsers1(LIMIT);
      return res?.items;
    },
    {
      refetchOnWindowFocus: false,
    },
  );
  const {
    data: users2,
    refetch: refetchUser2,
    isLoading: isLoading2,
  } = useQuery(
    REACT_QUERY_KEYS.USER2,
    async () => {
      setIsLoading(false);
      const res = await getUsers2(LIMIT);
      return res?.items;
    },
    {
      refetchOnWindowFocus: false,
    },
  );
  const {
    data: users3,
    refetch: refetchUsers3,
    isLoading: isLoading3,
  } = useQuery(
    REACT_QUERY_KEYS.USER3,
    async () => {
      setIsLoading(false);
      const res = await getUserNewMembers(LIMIT);
      return res?.items;
    },
    {
      refetchOnWindowFocus: false,
    },
  );

But there is a problem when an Item can appear in multiple lists (sliders), and I wanna when I edit the state in the item (exp: is_favorite: false -> true) it will update automatically all version of that item in every other list (slider). I was recommended use webSocket but I don't know exactly how to use it.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!