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

112
Views
Data is being added in the array but not showing on the UI until reload

I am posting new data to the backend. It is being sent successfully but the section where I fetched these data are not being updated until I press reload on the browser.

Here I am adding the code. Please let me know where am I making the problem? Thanks a lot.

//This is a custom hook where I am fetching data.
  const [products, setProducts] = useProductsHook();

  const handleAddProduct = () => {
    const newProduct = {
      name: productName,
      image: imageLink,
      desc: desc,
      price: +price,
      quantity: +quantity,
      supplier: supplierName,
    };
    axios.post("http://localhost:5000/api/products", newProduct).then((res) => {
      setProducts(products.concat(res.data));
      setProductName("");
      setImageLink("");
      setDesc("");
      setPrice("");
      setQuantity("");
      setSupplierName("");
    });
  };
about 4 years ago · Juan Pablo Isaza
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!