/
CharacterInfo.js
44 lines (42 loc) · 1.02 KB
/
CharacterInfo.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
40
41
42
43
44
import { connect } from 'react-redux'
const CharacterInfo = ({
character,
error,
fetchCharacter,
isFetchedOnServer = false,
}) => (
<div className="CharacterInfo">
{error ? (
<p>We encountered and error.</p>
) : (
<article>
<h3>Character: {character.name}</h3>
<p>birth year: {character.birth_year}</p>
<p>gender: {character.gender}</p>
<p>skin color: {character.skin_color}</p>
<p>eye color: {character.eye_color}</p>
</article>
)}
<p>
(was character fetched on server? - <b>{isFetchedOnServer.toString()})</b>
</p>
<style jsx>{`
article {
background-color: #528ce0;
border-radius: 15px;
padding: 15px;
width: 250px;
margin: 15px 0;
color: white;
}
button {
margin-right: 10px;
}
`}</style>
</div>
)
export default connect((state) => ({
character: state.character,
error: state.error,
isFetchedOnServer: state.isFetchedOnServer,
}))(CharacterInfo)