Only handle onclick in the button instead of stopping propagation

This commit is contained in:
Ivan Deskov 2020-05-24 21:12:06 +01:00
parent 1874dc4724
commit 1879caaa00

View File

@ -117,8 +117,7 @@ function AddItemForm({ onNewItem }) {
function ItemDisplay({ item, onItemUpdate, onItemRemoval }) { function ItemDisplay({ item, onItemUpdate, onItemRemoval }) {
const { Container, Row, Col, Button } = ReactBootstrap; const { Container, Row, Col, Button } = ReactBootstrap;
const toggleCompletion = (event) => { const toggleCompletion = () => {
event.stopPropagation()
fetch(`/items/${item.id}`, { fetch(`/items/${item.id}`, {
method: 'PUT', method: 'PUT',
body: JSON.stringify({ body: JSON.stringify({
@ -153,7 +152,6 @@ function ItemDisplay({ item, onItemUpdate, onItemRemoval }) {
} }
> >
<i <i
onClick={toggleCompletion}
className={`far ${ className={`far ${
item.completed ? 'fa-check-square' : 'fa-square' item.completed ? 'fa-check-square' : 'fa-square'
}`} }`}