/
TopicContent.jsx
61 lines (56 loc) · 1.09 KB
/
TopicContent.jsx
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
import React from 'react';
import Entry from './Entry.jsx';
var example_data = [
{
id: 1,
content: 'Lorem Ipsum Dolor Sit Amet',
user: 'ramazanemre',
date: '12.03.2021 Pazar'
},
{
id: 2,
content: 'Basit bir deneme',
user: 'admin',
date: '10.03.2021 Cuma',
},
{
id: 3,
content: 'Basit bir deneme',
user: 'admin',
date: '9.03.2021 Cuma',
},
{
id: 4,
content: 'Basit bir deneme',
user: 'admin',
date: '8.03.2021 Cuma',
},
];
function generate_entry(data) {
return (
<Entry content={data.content} username={data.user} date={data.date}/>
)
}
export default class TopicContent extends React.Component {
state = {
content: '',
};
render() {
return (
<React.Fragment>
<h1>{this.decoded}</h1>
{this.props.data.map(generate_entry)}
</React.Fragment>
)
}
constructor(props) {
super(props);
var name = window.location.pathname.split('/')[2];
if(name===undefined){
this.decoded = 'Merhaba!';
}
else{
this.decoded = decodeURIComponent(name);
}
}
}