J
J
japan1232018-10-23 23:44:31
React
japan123, 2018-10-23 23:44:31

How to apply multiple styles at once?

The Item component implements the logic: by clicking on the task - it is crossed out (completed), by clicking on the "important" button - the text becomes bold, at the same time the task can be important and completed or only important or completed. How to implement such logic?
https://codesandbox.io/s/9p1mql0r4

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-10-24
@japan123

Item component, onImportantClick handler - you need to stop the event bubbling so that it is not processed in onItemClick as well, i.e.:

onImportantClick = (e) => {
  e.stopPropagation();
  this.setState(({ important }) => ({
    important: !important
  }));
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question