-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathHome.js
55 lines (50 loc) · 1.39 KB
/
Home.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
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import useStyles from 'isomorphic-style-loader/useStyles';
import React from 'react';
import PropTypes from 'prop-types';
import s from './Home.css';
function Home({ loading, news }) {
useStyles(s);
return (
<div className={s.root}>
<div className={s.container}>
<h1>React.js News</h1>
{loading !== false
? 'Loading...'
: news.map(item => (
<article key={item.link} className={s.newsItem}>
<h1 className={s.newsTitle}>
<a href={item.link}>{item.title}</a>
</h1>
<div
className={s.newsDesc}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: item.content }}
/>
</article>
))}
</div>
</div>
);
}
Home.propTypes = {
loading: PropTypes.bool.isRequired,
news: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string.isRequired,
link: PropTypes.string.isRequired,
content: PropTypes.string,
}),
),
};
Home.defaultProps = {
news: [],
};
export default Home;