Wondering what’s next for npm?Check out our public roadmap! »

    react-instances

    0.1.0 • 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

    // Input.js
    import { withInstanceManage } from 'react-instances'
    
    class Input extends Component {
      state = { value: '' }
    
      clear = () => {
        this.setState({ value: this.state.value.toUpperCase() })
      }
    
      clear = () => {
        this.setState({ value: '' })
      }
    }
    
    export default withInstanceManage(Input)
    // App.js
    import Input from './Input'
    
    export default function App() {
      return <Input name="myInput" />
    }
    // anywhere in your awesome application
    import Input from './Input'
    
    const myInput = Input.getInstance('myInput')
    myInput.setState({ value: 'test' })
    myInput.upperCase()
    myInput.clear()

    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

    Install

    npm i react-instances

    DownloadsWeekly Downloads

    50

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    55.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar