-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathDisplay.js
39 lines (30 loc) · 1.07 KB
/
Display.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable jsx-a11y/img-redundant-alt */
import React, { useState } from 'react';
// eslint-disable-next-line no-unused-vars
import Loading from "./Loading";
import Show from "./Show";
import fetchShow from '../api/fetchShow';
const Display = (props) => {
const [show, setShow] = useState(null);
const [selectedSeason, setSelectedSeason] = useState("none");
const { displayFunc } = props;
const handleClick = () => {
fetchShow().then(data => {
setShow(data);
if (displayFunc) {
displayFunc();
}
});
}
const handleSelect = e => {
setSelectedSeason(e.target.value);
};
return (
<div>
<img className="poster-img" src='http://static.tvmaze.com/uploads/images/original_untouched/200/501942.jpg' alt="header image" />
<br/>
{ !show ? <button onClick={handleClick}>Press to Get Show Data</button> :<Show show={show} selectedSeason={selectedSeason} handleSelect={handleSelect}/> }
</div>
);
}
export default Display;