-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsefulLinks.jsx
More file actions
52 lines (47 loc) · 1.43 KB
/
UsefulLinks.jsx
File metadata and controls
52 lines (47 loc) · 1.43 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
49
50
define(function (require, exports, module) {
var React = require('react'),
Reflux = require('reflux'),
LinksActions = require('jsx!flux/actions/LinksActions'),
LinksStore = require('jsx!flux/stores/LinksStore'),
m = require('lib/tools').m;
var T = React.PropTypes;
var UsefulLinks = React.createClass({
mixins: [Reflux.listenTo(LinksStore, 'linksUpdate')],
propTypes: {
title: T.string.isRequired
},
getInitialState() {
return {
links: []
}
},
linksUpdate(data) {
this.setState({links: data.links});
},
componentDidMount() {
LinksActions.loadData();
},
render() {
if (!this.state.links.length) {
return <span/>;
}
var styles = {
item: {
paddingLeft: 30
}
};
var style = m(styles.item, this.props.style);
var items = this.state.links.map((item, key) =>
<li key={key}>
<a href={item.url} target="_blank">{item.title}</a>
</li>);
return (
<section>
<h4>{this.props.title}</h4>
<ul style={style}>{items}</ul>
</section>
);
}
});
module.exports = UsefulLinks;
});