-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUsefulLinks.js
More file actions
48 lines (44 loc) · 1.19 KB
/
UsefulLinks.js
File metadata and controls
48 lines (44 loc) · 1.19 KB
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
import React, {PropTypes} from 'react'
import Reflux from 'reflux'
import LinksActions from '../actions/LinksActions'
import LinksStore from '../stores/LinksStore'
import {m} from '../lib/tools'
const UsefulLinks = React.createClass({
mixins: [Reflux.listenTo(LinksStore, 'linksUpdate')],
propTypes: {
title: PropTypes.string.isRequired
},
getInitialState() {
return {
links: []
}
},
linksUpdate(data) {
this.setState({links: data.links});
},
componentWillMount() {
LinksActions.loadData();
},
render() {
if (!this.state.links.length) {
return <span/>;
}
const styles = {
item: {
paddingLeft: 30
}
};
const style = m(styles.item, this.props.style);
const items = this.state.links.map((item, key) =>
<li key={key}>
{item.title} (<a href={item.url} target="_blank">{item.url}</a>)
</li>);
return (
<div>
<b>{this.props.title}</b>
<ul style={style}>{items}</ul>
</div>
);
}
});
export default UsefulLinks