@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.
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>
);
}
}