2.0.0 • Published 5 years ago

radapter v2.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

rAdapter

rAdapter is a React component adapter for Angularjs applications. Aimed at providing a way to avoid rewriting legacy Angularjs applications upfront, and instead allows iterative replacement of Angular directives and components with React components.

rAdapter being imported into my app

Usage

Installation:

npm install radapter

Example:

    import radapter from 'radapter';
    import { MyTextBox, MyButton } from './my-react-components';

    // your application
    angular
        .module('my-cool-app', [])
        .constant('MY_CONSTANTS', { assetPath: 'www.google.com' })
        .component('myTextBox', radapter(MyTextBox)) // Registered as component
        .directive('myButton', () => radapter(MyButton)); // Registered as directive
        .directive('myImage', (MY_CONSTANTS) => radapter(MyImage, {
            defaultProps: { assetPath: MY_CONSTANTS.assetPath } // Injecting dependencies from Angular
        }));

    // In your templates
    <my-text-box
        class-name="textbox"
        type="text">
    </my-text-box>

    <my-button
        type="button"
        onClick="$ctrl.handleClick">
    </my-button>

API

radapter(Component, options)

A factory function that accepts a React component, infers bindings from propTypes (or manualProps) and returns an Angularjs directive. The directive returned is also interoperable with Angular components.

Component

type: React component

React component to be wrapped

options.manualProps

type: string[]

If the manualProps array is supplied to the factory, it will bypass inference of bindings via Component.propTypes in favour of the supplied manual props. This is useful if your component is written in TypeScript or does not rely on PropTypes.

options.defaultProps

type: object

defaultProps allow you to pass predefined variables into your component. This is a good place to pass in Angular dependencies.

2.0.0

5 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago