1.2.6 • Published 8 years ago
react-level-count v1.2.6
react-level-count
Live updating leveldb + react component for counting the k/v pairs under a prefix!
Example
import React from 'react'
import level from 'level'
import { Count } from 'react-level-count'
const db = level('/tmp/react-level-count')
class Example extends React.Component {
render () {
return (
<div>
Live count: <Count db={db} prefix="prefix" />
</div>
)
}
}Now the <Count /> component will always reflect the number of k/v pairs you have stored in your database with the prefix prefix.
Find a full example in /example:
$ npm install
$ npm run rebuild
$ npm start
Installation
$ npm install react-level-valueAPI
<Count db [prefix filter render] />
Use filter to pick what adds to the count, like so:
<Count
db={db}
filter={({ key, value }) => true}
/>Use render for a custom render function:
<Count
db={db}
render={count => <strong>{count}</strong>}
/>License
MIT