React.js bindings for Orbit.js
npm install react-orbitjsreact-orbitjs
=============




This package attempts to make it easier to work with
Orbit.js in a React
environment. In a nutshell it's a transform listener, updating
a component props with records as they are changed. If you're familiar
with redux in combination with
react-redux, you already know
how to use this package.
---
---
A big thank you to the author and contributers of the popular
react-redux package, as
react-orbitjs is largely based on their code.
Installation
------------
_react-orbitjs requires Orbit 0.16.x or 0.17.x._
_npm_
```
npm install --save react-orbitjs
_yarn_
``
yarn add react-orbitjs
API
---
`jsx
const store = new MemorySource({schema})
// Simply pass a reference to your Orbit store to the
// and wrap your root App component. The provider makes a dataStore child
// context available to all children, which is consumed by the HOC generated
// with the withData() connector.
ReactDOM.render(
rootElement
)
`
`jsx
// This mapper uses the props passed in to manipulate the queries. Useful for
// sort/filter functions, etc.
const mapRecordsToProps = (ownProps) => {
return {
planets: q => q.findRecords("planet").sort(ownProps.sortBy),
}
}
// Or use a simple object if you don't use the props in your queries.
const mapRecordsToProps = {
planets: q => q.findRecords("planet"),
}
// Export the generated component. Your
// the props you pass to the wrapper component, combined with the results from
// the queries defined in the mapRecordsToProps function or object, and
// convenience queryStore and updateStore props, which defer to store.query and
// store.update.
export default PlanetariumWithData = withData(mapRecordsToProps)(Planetarium)
``
License
-------
MIT