Kirill Stas Kirill Stas - 1 year ago 149
React JSX Question

change object.item in setState

how can i change item in object in getInitialState through setState ?

For example:

getInitialState: function() {
return {list: [
title: 'The Baby Boss',
year: '2017',
quality: 'Blu-ray',
stars: ['Fred Astaire, ', 'Humphrey Bogart, ', 'Marlon Brando, ', 'Richard Burton, ', 'Charlie Chaplin'],
Show: false
title: 'Pirates of the Caribbean: Dead Men Tell No Tales ',
year: '2016',
quality: 'HDrip',
stars: ['John Depp, ', 'Orlando Bloom, ', 'Javier Bardem, ', 'Kaya Scodelario, ', 'Brenton Thwaites'],
Show: true

More clear. I have created
and than
ed it and get on the screen displaying of list objects. I have button and I want click it and change smth in one of the objects. Through items in list i go with 'map' function. As result, I am trying to do smth like this code below:

film.Show: false

But this way doesn`t work. Which way of getting to my aim is correct ?Thanks for ideas.

Answer Source

You need to find your target item and update that:

someEventHandler: function(targetId) {
      list: {
         if ( === targetId) {
            film.Show = false;
         return film;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download