Skip to content

Tag: reactjs

Updating the localStorage is not in sync

When I toggle darkmode it doesn’t update in _app unless I have 2 tabs opened and trigger it in one tab, then the other tab gets updated and darkmode is toggled, but not the tab I pressed the toggle. I use useSettings in both index and _app. I recorded a video so it’s easier to see what’s goi…

Change component state – REACT

I’m currently working on a project with the Pokemon API and i’m facing a problem. I want to change the value parameter in the async function getPokemonTypes(), but the value I receive in handleSelect() is not working. On the console.log(value), the value changes every time I select a different opt…

Why is my component not loading through Vite

I am building a React project with Vite. I was using a tutorial from an article that I found at https://www.digitalocean.com/community/tutorials/how-to-set-up-a-react-project-with-vite. I followed the tutorial as described, however, my “greeting” component will not load. Answer Components should s…

Why is fetch calling api multiple times in react?

I have a very basic api and all it does is return the text “Sunny day”. I create a react project using create react app and try to call the api once then printing result to the console. Here is the react app The problem is the api is getting called twice on page load Can anybody explain why? Answe…