-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import Data from './data' | ||
|
||
import './main.css' | ||
|
||
const App = ({ title, api }) => ( | ||
<main> | ||
<h1>{title}</h1> | ||
<div className='logo' /> | ||
<Data api={api} /> | ||
</main> | ||
) | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* global fetch */ | ||
|
||
import React, { Component } from 'react' | ||
|
||
class Data extends Component { | ||
constructor (...args) { | ||
super(...args) | ||
this.state = { data: null } | ||
} | ||
|
||
componentWillMount () { | ||
loadData(this.props.api) | ||
.then(data => { this.setState({ data }) }) | ||
.catch(console.error) | ||
} | ||
|
||
render () { | ||
if (this.state.data === null) return null | ||
return <p>{this.state.data.uuid}</p> | ||
} | ||
} | ||
|
||
const loadData = api => fetch(`${api}/uuid`).then(d => d.json()) | ||
|
||
export default Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters