would someone please help
when i write a link to be shortened it gives me the previous result. I want to understand why?
this is my first time building a website with api so any recommendation for improving are welcome
live site: https://shorty-url-shortening-api.vercel.app/
repo: GitHub - onna4/shorty-URL-shortening-API: shorty URL shortening API built with react
i used useEffect with fetch to get the data. and I’m storing it in localStorage
first of, cool design
useEffect(() => {
localStorage.setItem("linkData", JSON.stringify(dataArray))
}, [dataArray])
you need to re think your “useEffect” dependency to trigger to get recent data
to me, currently it seems like its always going to be “same data” unless your “components are re-rendering” after each form submit
hope this helps, happy coding
1 Like
well i’m updating the state of dataArray and it suppose to trigger a re-render in the app… why it acts like that? when I console log the dataArray it gets the updated data but the one in local storage isn’t updates.
system
Closed
November 29, 2023, 11:12pm
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.