renaming
This commit is contained in:
parent
6079f265fd
commit
1e38cd840b
5 changed files with 52 additions and 20 deletions
1
src/components/Channel/ChannelList.scss
Normal file
1
src/components/Channel/ChannelList.scss
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.channelList li span {}
|
41
src/components/Channel/ChannelList.tsx
Normal file
41
src/components/Channel/ChannelList.tsx
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import ChannelService from '../../services/chanel';
|
||||||
|
|
||||||
|
import './ChannelList.scss';
|
||||||
|
|
||||||
|
export default class Channellist extends Component<any, any> {
|
||||||
|
service: ChannelService;
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
loaded: false,
|
||||||
|
channels: [],
|
||||||
|
};
|
||||||
|
this.service = new ChannelService();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
fetch('http://haveachin.de:1888/v1/channels')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => this.setState({ channels: data, loaded: true }))
|
||||||
|
.catch(e => console.log(e));
|
||||||
|
}
|
||||||
|
public render() {
|
||||||
|
const { loaded, channels } = this.state;
|
||||||
|
console.log(this.state);
|
||||||
|
if (!loaded) {
|
||||||
|
return <div className='loading'>Loading...</div>;
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<ul className='channelList'>
|
||||||
|
{channels.map((e: Channel) => (
|
||||||
|
<li>
|
||||||
|
<span>#{e.id} </span>
|
||||||
|
{e.name}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
src/components/Channel/ChannelView.scss
Normal file
10
src/components/Channel/ChannelView.scss
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
.channel-view {
|
||||||
|
background-color: green;
|
||||||
|
width: 20%;
|
||||||
|
height: auto;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-view ul {
|
||||||
|
text-align: left
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
export default class Channellist extends Component<any, any> {
|
|
||||||
constructor(props: any) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
data: 'Loading...',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
fetch('https://ts.cliffbreak.de/v1/channels')
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => this.setState({ data }));
|
|
||||||
}
|
|
||||||
public render() {
|
|
||||||
const { data } = this.state;
|
|
||||||
return <div>{data}</div>;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue