Created
June 8, 2018 23:55
-
-
Save Lucifier129/4d6615102dda4828dd8f2b1dc6817b8d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import React from 'react' | |
| import ReactDOM from 'react-dom' | |
| import { reactive } from 'rxjs-react' | |
| import { from } from 'rxjs' | |
| import { map } from 'rxjs/operators' | |
| @reactive | |
| class App extends React.Component { | |
| data$ = from(fetch(this.props.url).then(res => res.json())) | |
| render() { | |
| return ( | |
| <React.Fragment> | |
| <h1>data from github api</h1> | |
| <pre> | |
| {this.data$.pipe( | |
| map(data => { | |
| return JSON.stringify(data, null, 2) | |
| }) | |
| )} | |
| </pre> | |
| </React.Fragment> | |
| ) | |
| } | |
| } | |
| ReactDOM.render( | |
| <App url="https://api.github.com/repos/lucifier129/rxjs-react" />, | |
| document.getElementById('root') | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment