react-instances
v0.1.2
Published
The library that manages React components instances
Downloads
29
Maintainers
Readme
react-instances
The library that manages React Component instances
This library is under construction and not stable right now. It is planned to release the first stable version on May 17, 2021 (or maybe sooner).
Install
npm install --save react-instances
Introduce
// anywhere in your awesome application
import Input from './Input'
const myInput = Input.getInstance('myInput')
myInput.setState({ value: 'test' })
myInput.upperCase()
myInput.clear()
// App.js
import Input from './Input'
export default function App() {
return <Input name='myInput' />
}
// Input.js
import { withInstanceManage } from 'react-instances'
class Input extends Component {
state = { value: '' }
upperCase = () => {
this.setState({ value: this.state.value.toUpperCase() })
}
clear = () => {
this.setState({ value: '' })
}
}
export default withInstanceManage(Input)
Demo & Documents
Communication
Decisions tree
What do you need?
I want to interactive with
My class component
My function component
My hook
I want to watch the changes of
My class component
- Not supported yet
My function component
My hook
I want to do both with
My class component
- Not supported yet
My function component
My hook
License
MIT © unique01082