Avoid sending duplicate PUT requests when toggling completion

This commit is contained in:
Ivan Deskov 2020-05-24 00:13:24 +01:00
parent 6d6a950908
commit 1874dc4724

View File

@ -117,7 +117,8 @@ 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 = () => { const toggleCompletion = (event) => {
event.stopPropagation()
fetch(`/items/${item.id}`, { fetch(`/items/${item.id}`, {
method: 'PUT', method: 'PUT',
body: JSON.stringify({ body: JSON.stringify({