All Projects → Workable → backbone.react-bridge

Workable / backbone.react-bridge

Licence: MIT license
Transform Backbone views to React components and vice versa

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to backbone.react-bridge

NestedReact
BackboneJS compatibility layer for React-MVx MVVM framework.
Stars: ✭ 79 (+203.85%)
Mutual labels:  backbone
universal-react-webpack-boilerplate
unireact - quickly bootstrap your universal react-app
Stars: ✭ 27 (+3.85%)
Mutual labels:  react-components
react-dailymotion
Dailymotion player component for React.
Stars: ✭ 14 (-46.15%)
Mutual labels:  react-components
backscatter
Reactive extension for Backbone
Stars: ✭ 17 (-34.62%)
Mutual labels:  backbone
lundium
React UI library for fast web development.
Stars: ✭ 24 (-7.69%)
Mutual labels:  react-components
react-guidebook
📚 React 知识图谱 关于概念、技巧、生态、前沿、源码核心
Stars: ✭ 22 (-15.38%)
Mutual labels:  react-components
Awesome-Vision-Transformer-Collection
Variants of Vision Transformer and its downstream tasks
Stars: ✭ 124 (+376.92%)
Mutual labels:  backbone
neptune-web
Wise Web Design System
Stars: ✭ 55 (+111.54%)
Mutual labels:  react-components
Stardust
🎨Tiller Design System
Stars: ✭ 19 (-26.92%)
Mutual labels:  react-components
reactivebase
Data components for building reactive UIs
Stars: ✭ 18 (-30.77%)
Mutual labels:  react-components
babel-plugin-transform-react-qa-classes
Add component's name in `data-qa` attributes to React Components
Stars: ✭ 41 (+57.69%)
Mutual labels:  react-components
marionette.routing
State based router for MarionetteJS
Stars: ✭ 21 (-19.23%)
Mutual labels:  backbone
react-circle-flags
🚀 A React component with a collection of 300+ minimal circular SVG country flags. Wrapper of HatScripts/circle-flags
Stars: ✭ 29 (+11.54%)
Mutual labels:  react-components
fyndiq-ui
Library of reusable web frontend components for Fyndiq
Stars: ✭ 39 (+50%)
Mutual labels:  react-components
react-functional-select
Micro-sized & micro-optimized select component for React.js
Stars: ✭ 165 (+534.62%)
Mutual labels:  react-components
animation-wrapper-view
Declarative animations with imperative controls for RN/RNW.
Stars: ✭ 53 (+103.85%)
Mutual labels:  react-components
delete-react-zombies
CLI to search and delete unimported 🧟components in your react ⚛️ files
Stars: ✭ 70 (+169.23%)
Mutual labels:  react-components
basic-todo-app-using-bit
A highly-modular React todo application composed of reusable components from 5 different collections. Full-blown software modularity.
Stars: ✭ 16 (-38.46%)
Mutual labels:  react-components
react-discord-message
React components to easily build and display fake Discord messages on your webpages.
Stars: ✭ 24 (-7.69%)
Mutual labels:  react-components
react-scaffolder
⚡ Scaffolding tool for React
Stars: ✭ 43 (+65.38%)
Mutual labels:  react-components

Backbone.ReactBridge

build status npm version npm version

A toolkit for transforming Backbone views to React components and vice versa. 🚀

Installation

$ npm install --save-dev backbone.react-bridge

Usage

React Component ➡️ 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, {

    // Provide a model for the Backbone.View

    model: fooModel,

    // Provide a collection for the Backbone.View

    collection: fooCollection,

    // By default the view gets re-rendered
    // on model "change" and collection "add remove reset" events
    // But you can override this using the `observe` property

    observe: {
      model: 'change',
      collection: 'reset add remove'
    },

    // Define custom properties which will be passed to the React Component.
    // In case that the properties overlap with the model attributes,
    // the values of the model will be ovewritten.

    props: {
      title: 'Foo Title',
      subtitle: 'Foo Subtitle'
    },

    // Customize the form of the properties which will be passed to the
    // React Component. In case that 'getProps' is undefined, a composition
    // of the model's attributes, the collection's values and the custom
    // properties will be returned to the React Component.
    // `getProps` receives an object with `model` and `collection` as properties.

    getProps({collection, model}) {
      return {
        titles: collection.map((m) => {title: m.get('title').toUpperCase()}),
        content: model.get('content')
      }
    }

});

fooView.render();

// Or if using Marionette.js

region.show(fooView);

None of the options described above are required in order to use the viewFromComponent function.

Backbone View ➡️ 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, {

    // Override the default tagName of the element which will wrap
    // the React Component. If not provided, the default tagName
    // according to Backbone will be used

    tagName: 'ul',

    // Add a custom class on the element which will wrap the React Component

    className: 'barClass',

    // Using Redux? We got you covered!
    // You can define actions that will be dispatched when
    // specific events are triggered from the Backbone View.
    // This feature requires a reference of the store's dispatch function

    eventsToActions : {
      // Dispatch a "BAR_SUBMIT" action when a "submit" event is triggered by the view
      'submit': () => ({type: 'BAR_SUBMIT'})
    }

    // A reference to the Redux store's dispatch function. This function is
    // used to dispatch the actions registered via the eventToActions option

    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! 😊

Build

$ npm run build

Test & Coverage

$ npm run coverage
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].