Skip to content

Instantly share code, notes, and snippets.

@spacegauch0
Last active April 26, 2017 21:00
Show Gist options
  • Select an option

  • Save spacegauch0/f2275a112b9f82a9857e4d7a6912fd49 to your computer and use it in GitHub Desktop.

Select an option

Save spacegauch0/f2275a112b9f82a9857e4d7a6912fd49 to your computer and use it in GitHub Desktop.
import PouchDBChanges from 'react-pouchdb-changes'
import React from 'react'
export default class extends React.Component {
state = { latestDoc: null }
changeHandler = (change) => {
this.setState({ latestDoc: change.doc })
}
render () {
return(
<div>
<PouchDBChanges
dbUrl='http://couch-01.db.precioslibres.org/precios_claros_dump-01'
changesOpts={{ since: 'now', live: true, include_docs: true }}
onChange={change => this.setState({ latestDoc: change.doc })}
onError={err => this.handleError(err)}
>
<p>{this.state.latestDoc ? this.state.latestDoc.uuid : 'loading...'}</p>
</PouchDBChanges>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment