Skip to content

Tag: reactjs

Axios Undefined Response

I am Developing MERN Stack Project. The problem is when I make the first API Call the first response is undefined and the map function gives an error ‘Map is not a function and it makes sense. the problem is i tried several approaches to prevent this from happening but it won’t work This is the Co…

Conditional link styling React

I want my nav bar to style the page title I’m in, im using React and Tailwind CSS, for example, just make the title yellow when im on the selected path. My logic to achieve that would be this but isn’t working: My rout code: Nav bar code: Answer Well at the end the problem was the path variable wh…

How to useFetch with a for loop?

I am creating an application with react. I have to fetch several data. This is my fetch statement: At the end of the line, it is a 6 but I have this kind of problem. I have periods and these periods are changed for every object. I call the period from there and I find the length of periods like

Send order to children

Basically, as above, there is the Accordion components and a parent component that hosts all of them. Each Accordion component has a state called open. I want to change state of each child from parent component. How can I send an order to a child component to change its state? Answer Lift your state up into P…

React never ending loop in useEffect

Apologies. React noob here. Got an issue where my code has stuck on a never ending loop. I’ve stripped the code down only to the part I believe that’s causing the problem. I’ve used the useEffect method to match the componentDidMount. Is that correct? The moment I comment “setPackages(…