Skip to content

Instantly share code, notes, and snippets.

@Lucifier129
Created June 8, 2018 23:55
Show Gist options
  • Select an option

  • Save Lucifier129/4d6615102dda4828dd8f2b1dc6817b8d to your computer and use it in GitHub Desktop.

Select an option

Save Lucifier129/4d6615102dda4828dd8f2b1dc6817b8d to your computer and use it in GitHub Desktop.
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