Backbone.ReactBridge
![npm version](https://img.shields.io/npm/dm/backbone.react-bridge.svg?style=flat-square)
A toolkit for transforming Backbone views to React components and vice versa. :rocket:
Installation
$ npm install --save-dev backbone.react-bridge
Usage
React Component :arrow_right: Backbone View
This function allows you to get a Backbone.View from a React component. It accepts as input a React Component instance or class along with some extra options.
Full blown example with available options:
const fooView = ReactBridge.viewFromComponent(FooComponent, {
model: fooModel,
collection: fooCollection,
observe: {
model: 'change',
collection: 'reset add remove'
},
props: {
title: 'Foo Title',
subtitle: 'Foo Subtitle'
},
getProps() {
return {
titles: this.collection.map((m) => {title: m.get('title').toUpperCase()})
}
}
});
fooView.render();
region.show(fooView);
None of the options described above are required in order to use the viewFromComponent function.
Backbone View :arrow_right: React Component
This function allows you to get a React component from a Backbone view. It accepts either a Backbone.View instance or class along with some extra options.
Full blown example with available options:
const Bar = ReactBridge.componentFromView(BarView, {
tagName: 'ul',
className: 'barClass',
eventsToActions : {
'submit': () => ({type: 'BAR_SUBMIT'})
}
dispatch: store.dispatch
});
ReactDOM.render(<Bar />, document.querySelector('#bar'));
None of the options described above are required in order to use the componentFromView function.
Examples
$ npm install
$ npm start
Enjoy! :blush:
Build
$ npm run build
Test & Coverage
$ npm run coverage