Skip to content

Instantly share code, notes, and snippets.

@couzic
Last active March 17, 2017 13:55
Show Gist options
  • Select an option

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

Select an option

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