@anteniyus/react-plus-component

1.0.6 • Public • Published

@anteniyus/react-plus-component

A general component that can add or remove a specific component and also gives you the state of all existing components.

NPM JavaScript Style Guide

Install

npm install --save @anteniyus/react-plus-component

Usage

import React, { Component } from 'react'

import MyComponent from '@anteniyus/react-plus-component'

class Example extends Component {
  render() {
    return <MyComponent />
  }
}

Here is an example of using react-plus-component

import React, { Component } from 'react';

import { PlusComponent } from '@reza/react-plus-component';
import RepeatComponent from './Repeat';

export default class App extends Component {
  constructor(props) {
    super(props)
    this.ref = React.createRef()
  }

  add = () => {
    return this.ref.current.addComponent();
  };

  remove = () => {
    return this.ref.current.removeComponent();
  };

  getState = () => {
    return this.ref.current.getState();
  };

  render() {
    return (
      <div>
        <button onClick={this.add}>add</button>
        <button onClick={this.remove}>remove</button>
        <PlusComponent ref={this.ref} component={<RepeatComponent />}/>
      </div>
    );
  }

}

License

MIT © Reza

react-plus-component

Package Sidebar

Install

npm i @anteniyus/react-plus-component

Weekly Downloads

5

Version

1.0.6

License

MIT

Unpacked Size

245 kB

Total Files

7

Last publish

Collaborators

  • anteniyus