Skip to content
Advertisement

Push data inside an array index. React Native JSX

I am trying to compare, find and push data inside an array. But getting following error

Error => TypeError: undefined is not an object (evaluating ‘data[index].push’)

I have following JSON/Array

JavaScript

I want to push packages object inside matching category so json/array will be as follows

JavaScript

Following is the code what I was trying to do:

JavaScript

Advertisement

Answer

I don’t know how your packages array look like, but this should give you the expected result:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement