Skip to content
Advertisement

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: }, [selectedLayerIndex]); Thank you so

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 the indices and an array

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 checks. The first one is for

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 “/” or http://localhost:3000/ This is

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 at this point.

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 field’s values, I will still get the

React Router v6 useRouteMatch equivalent

When using React Router v5, it was possible to get the path (pattern) for that route using useRouteMatch. React Router v6 offers a similar hook, useMatch; however this expects to receive the pattern you want to match against. I would use the React Router v5 hook to generate routes by combining the current path with known params. As an example,

Advertisement