0.0.1 • Published 2 years ago

react-monit v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Imitation

react state - extra

main function

Imitation.assignState assign the Imitation state and dispatch the Imitation update

Imitation.setState set the Imitation state and dispatch the Imitation update

Imitation.withBindRender with the hoc funcion the app funtion can be update by Imitation.dispatch

how to use

example:

import Imitation from 'imitation'

Imitation.state = { name: 'jack', address: 'japan' }

export default Imitation
import React from 'react'
import Imitation from './CreateImitation'

function A() {
  return <input onChange={e => Imitation.assignState({ name: e.target.value })} value={Imitation.state.name} />
}
const Ar = Imitation.withBindRender(A, state => [state.name])


function App() {
  return <div>
    <div>
      <div>{Imitation.state.name}</div>
      <div>{Imitation.state.address}</div>
    </div>
    <Br />
  </div>
}

export default Imitation.withBindRender(App, state => [state.name, state.address])