insert to an array item

This feature is designed for you if you have an array and wish to insert a state into a specific item within that array.

There are 2 optional parameters in case you want to insert the object to an item in an array The value of the item that we want to find The key of the value

dispatch(insert('DESTINATION', 'OBJECT-NAME', PAYLOAD, VALUE, KEY )); 

Example: We want to insert { Nickname: ['Crawfish','Crawdad','Crayfish']} to the item that has id = 2 in the Users array. So the value is 2 and the key is id.

dispatch(insert('Users', "Nickname", ['Crawfish','Crawdad','Crayfish'], 2, 'id'));

Last updated