Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

react-wiring

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-wiring

Wire together react components with bare-bones redux like state flow using React Contexts.

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

React Wiring

Wire together react components with bare-bones redux like state flow using React Contexts.

Install

yarn add https://github.com/daywiss/react-wiring

Usage

import React from 'react'
import Wiring from 'react-wiring'

//default state you want your component props to see
const defaultState = {
  initialized:false
}

//design your state reducers
const reducers = {
  initialize(state,initialized){
    return {
      ...state,
      initialized
    }
  }
}

const wiring = Wiring(React,defaultState,reducers)

let {Provider,dispatch,connect} = wiring

//this is the main app. 
const App = connect(props=>{
  //"dispatch" will get passed in plus the default state
  const {dispatch,initialized} = props

  return <div>
    Initialized {initialized}
    <Button onClick={e=>dispatch('initialize')(true)} />
  </div>
})

//initilize react app
const anchor = document.getElementById("app");            
ReactDOM.render(                                           
  <Provider>                                    
    <App/>                                                 
  </Provider>,                                             
  anchor                                                  
)

FAQs

Package last updated on 25 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts