Skip to content

Instantly share code, notes, and snippets.

@couzic
Created March 16, 2017 09:49
Show Gist options
  • Select an option

  • Save couzic/cbd4cf73f5f4fc2a8f57b2bb48c1d46c to your computer and use it in GitHub Desktop.

Select an option

Save couzic/cbd4cf73f5f4fc2a8f57b2bb48c1d46c to your computer and use it in GitHub Desktop.
react-rx-pure-connect Advanced Example
import {connect} from 'react-rx-pure-connect'
const Component = (props: {name: string}) => <h2>Name: {props.name}</h2>
const mapProps = (props: {personId: number}) => Observable.ajax
.getJSON(`/api/person/${props.personId}`)
.map(person => ({name: person.name}))
const Name = connect(mapProps)(Component)
// Rendered as "<h2>Name: Bob</h2>"
<Name personId={123} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment