Skip to content

Tag: arrays

Assign ref dynamically inside concat in react render

I have an array of objects which I create on pressing the add button.The add handler function is as below. This create multiple EditContainer elements all of which share the same ref.How can I create refs like this on the fly for a dynamic array of Object which is a state Answer editContainerRefs.current will…

How can I find objects with same keys values in array?

I have an array of objects that looks like this: And I need to find objects with the same type to merge fields key in them, like this: My plan was to filter through the array, but my problem is that I don’t know which type will send me API, so filtering by item.type wouldn’t work for me. Answer If