-
Notifications
You must be signed in to change notification settings - Fork 88
/
App.js
62 lines (58 loc) 路 1.31 KB
/
App.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { Component } from "react";
import { connect } from "react-redux";
import styled from "styled-components";
import Article from "../components/Article";
import Clap from "../components/Clap";
import { fetchArticleDetails } from "../actions";
const StyledApp = styled.div`
min-height: 100vh;
display: flex;
align-items: center;
aside {
min-width: 35vh;
display: flex;
justify-content: flex-end;
}
main {
flex: 1 0 350px;
${"" /* not responsive */} padding: 0 5rem;
}
`;
class App extends Component {
state = {};
componentDidMount() {
this.props.fetchArticleDetails();
}
render() {
const { title, subtitle, paragraphs } = this.props.data;
const countTotal = this.props.data.numberOfRecommends;
return (
<StyledApp>
<aside>
<Clap countTotal={countTotal} />
</aside>
<main>
{this.props.isLoadingData ? (
"Loading . . ."
) : (
<Article
title={title}
subtitle={subtitle}
paragraphs={paragraphs}
/>
)}
</main>
</StyledApp>
);
}
}
const mapStateToProps = ({ data = {}, isLoadingData = false }) => ({
data,
isLoadingData
});
export default connect(
mapStateToProps,
{
fetchArticleDetails
}
)(App);