react-instances

0.1.2 • Public • Published

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).

NPM JavaScript Style Guide

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

API

Communication

Discussion

Discord

Contact point

Decisions tree

react-instance-decisions-tree

What do you need?

I want to interactive with

  • My class component

    • withInstanceManage Open in CodeSandbox
  • My function component

    • manageInstances & useInstanceManage Open in CodeSandbox
  • My hook

    • withHookInstanceManage Open in CodeSandbox
    • manageInstances & useInstanceManage Open in CodeSandbox

I want to watch the changes of

  • My class component

    • Not supported yet
  • My function component

    • observable & useObserversNotify Open in CodeSandbox
  • My hook

    • withHookObserversNotify Open in CodeSandbox
    • observable & useObserversNotify Open in CodeSandbox

I want to do both with

  • My class component

    • Not supported yet
  • My function component

    • manageInstances & useInstancemanage & observable & useObserversNotify Open in CodeSandbox
  • My hook

    • withHookManage Open in CodeSandbox
    • manageInstances & useInstancemanage & observable & useObserversNotify Open in CodeSandbox

License

MIT © unique01082

Package Sidebar

Install

npm i react-instances

Weekly Downloads

12

Version

0.1.2

License

MIT

Unpacked Size

37.2 kB

Total Files

7

Last publish

Collaborators

  • baolq