Skip to content

Tag: reactjs

How to save the name of object in array object?

I have an array containing 7 objects named is NewClass. When I make some changes to the objects, the object has lost its original NewClass name. Like that: In arrray[6] lost NewClass name. So is there any way I can keep the NewClass name for that object? Here is my function to handle this array: }, [selectedL…

How to sort an array with special conditions

I just want to return an array containing the first and second objects based on the “point” property of an object and I have a condition below, When the condition is satisfied it will swap places. Given the following object: the result I want is Answer You could group the data with an object for t…

The object empty check is not working and changing the logic

So I am doing a form validation check and I have taken ‘formErrors’ and set the errors in this object. However it is initially {} and in my code I am checking for Object.keys(formErrors).length===0 which returns true for even {} So When I submit the handleSubmit() method is run and it has 2 nested…

react components not rendering with routes

I am using the latest version of react router. When I am using routes in my component, They are not rendering anything but When I remove the routes and use simply the component they are working fine. Not able to understand what is going wrong This do not work and is not rendering anything on “/” o…

React is not showing anything on the screen

I was using function instead of class and the code was working up to certain extent, now it is not displaying at all. In my VehiclesList.js I generate 10 random vehicles, code below: In my vehicle.js I have to show the info of the clicked vehicle, react is not showing anything on the screen and I’m lost…

React Hooks useState() with an Array of Object

while I am creating new “Todo” and modifying the fields are no problem my issue is receiving back the child data when I click the “show all objects” button. Here is a code example to illustrate my issue: if I click twice on the “add a Todo” button and change one of the fiel…