From 70c7aa60dcdb6f774798117793320cc546226605 Mon Sep 17 00:00:00 2001 From: 123niel Date: Wed, 6 Feb 2019 23:30:58 +0100 Subject: [PATCH] trying to fetch data --- src/App.css | 33 ++++------------------------ src/App.tsx | 25 +++++++-------------- src/components/Header/Header.css | 10 +++++++++ src/components/Header/Header.tsx | 9 ++++++++ src/components/channels/Channels.tsx | 20 +++++++++++++++++ 5 files changed, 51 insertions(+), 46 deletions(-) create mode 100644 src/components/Header/Header.css create mode 100644 src/components/Header/Header.tsx create mode 100644 src/components/channels/Channels.tsx diff --git a/src/App.css b/src/App.css index 92f956e..c84d958 100755 --- a/src/App.css +++ b/src/App.css @@ -1,32 +1,7 @@ +body { + background-color: pink; +} + .App { text-align: center; } - -.App-logo { - animation: App-logo-spin infinite 20s linear; - height: 40vmin; -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.tsx b/src/App.tsx index ff5a4a6..a992516 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,25 +1,16 @@ import React, { Component } from 'react'; -import logo from './logo.svg'; + +import Channels from './components/channels/Channels'; +import Header from './components/Header/Header'; + import './App.css'; class App extends Component { - render() { + public render() { return ( -
-
- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
+
+
+
); } diff --git a/src/components/Header/Header.css b/src/components/Header/Header.css new file mode 100644 index 0000000..ac52886 --- /dev/null +++ b/src/components/Header/Header.css @@ -0,0 +1,10 @@ +.App-header { + background-color: #282c34; + min-height: 100px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx new file mode 100644 index 0000000..5c67fea --- /dev/null +++ b/src/components/Header/Header.tsx @@ -0,0 +1,9 @@ +import React, { Component } from 'react'; +import './Header.css'; +class Header extends Component { + public render() { + return
Cliffbreak.de
; + } +} + +export default Header; diff --git a/src/components/channels/Channels.tsx b/src/components/channels/Channels.tsx new file mode 100644 index 0000000..217fa2b --- /dev/null +++ b/src/components/channels/Channels.tsx @@ -0,0 +1,20 @@ +import React, { Component } from 'react'; + +export default class Channels extends Component { + 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
{data}
; + } +}