react-huc

huc means hub component

Usage no npm install needed!

<script type="module">
  import reactHuc from 'https://cdn.skypack.dev/react-huc';
</script>

README

React Huc

React Huc is a container

Install

$ npm install react-huc -S

usage

import Huc from 'react-huc'

<Huc initStore={{isShow: false}}>
 <Child1 />
 <Child2 />
</Huc>

//Child1
render() {
  const {isShow} = this.props
  return (
    <div>{isShow}</div>
  )
}

//Chil2

render(){
  const {isShow, dispatch} = this.props
  return (
    <div>
    <button onClick={()=> dispatch({isShow: !isShow})}>toggle</button>
    </div>
  )
}