Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export const BookInformation: React.FC<Props & DependenciesProps> = ({
bookTitle,
dependencies
}) => {
const [book, setBook] = useState<BookDetails>()
const onRefresh = () => fetchBookInformation()
useEffect(() => {
fetchBookInformation()
}, [])
return (
<div>
<h1>Available books</h1>
<button data-testid="refresh-button" onClick={onRefresh}>Refresh page</button>
<BookInformationCard book={book}/>
</div>
)
function fetchBookInformation() {
dependencies
.bookInformation(bookTitle)
.then(res => setBook(res))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment