From 345dcdd9ff58934fb414689ab4e9004617bfbcc7 Mon Sep 17 00:00:00 2001 From: haerong22 Date: Mon, 8 Feb 2021 21:15:38 +0900 Subject: [PATCH] =?UTF-8?q?react-springboot=20:=20=EC=B1=85=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/book-frontend/src/pages/book/Detail.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/react-springboot/book/book-frontend/src/pages/book/Detail.js b/react-springboot/book/book-frontend/src/pages/book/Detail.js index fa3d5d17..a17e9df8 100644 --- a/react-springboot/book/book-frontend/src/pages/book/Detail.js +++ b/react-springboot/book/book-frontend/src/pages/book/Detail.js @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react'; +import { Button } from 'react-bootstrap'; const Detail = (props) => { const id = props.match.params.id; @@ -15,11 +16,25 @@ const Detail = (props) => { .then((res) => { setBook(res); }); - }, []); + }, [id]); + + const deleteBook = () => { + fetch('http://localhost:8080/book/' + id, { + method: 'delete', + }) + .then((res) => res.text()) + .then((res) => { + res === 'ok' ? props.history.push('/') : alert('삭제실패'); + }); + }; return (

책 상세보기

+ {' '} +

{book.author}

{book.title}