0

I have a table with 50 rows, each row is an item from a list.

I want to set the item as selected when I click on a checkbox in the row.

By doing it, I see that all the 50 rows are rerender.

How can I set only the specific item? (Without shouldcomponentupdate).

case ITEM_SELECTED:
        const items = fromJS(state.items)
            items.update(
            items.findIndex(function(item) {
                return item._id == action.id;
            }), function(item) {
                return item.selected = action.selected;
            }
        );
        return {
            ...state,
            items: items.toJS()
        }

Thanks :)

3
  • A. No attempted code provide. B. Very open ended. C. Sad Panda. Commented Mar 26, 2017 at 15:53
  • can share some code also, table as well as the function in which doing the selection :) Commented Mar 26, 2017 at 15:53
  • By connecting individual row components rather than a containing component you should be able to avoid the re-render, although I wouldn't bother doing that under most circumstances. As other users mentioned, some more detail would help us answer your question better. Commented Mar 26, 2017 at 15:58

1 Answer 1

1

Did you add key to each item ? React uses key to determine if a sibling has changed.

https://facebook.github.io/react/docs/lists-and-keys.html#keys

1
  • you have sufficient reputation to comment on any ques, so instead of asking ques as an answer, ask it in comments, post the answer when it actually answer the OP's ques :) Commented Mar 26, 2017 at 16:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.