Giter Site home page Giter Site logo

dynamic-redux's Introduction

Dynamic redux

With dynamic redux you can inject your reducers on the fly

Install Requirements

[email protected]:~$ npm install redux react-redux redux-thunk

Setup

Then simply copy src folder into your project where you want preferably a directory named Data

Import it

import ReduxProvider from './ReduxProvider'

Wrap your root component or any base component

ReactDOM.render(
    <ReduxProvider>
        <Application />
    </ReduxProvider>, document.getElementById('root'));

Injecting a reducer

Import the store and your reducer

import CounterReducer from './Reducers/MyReducer'
import Store from './Data/Store'

Inject your reducer

// First parameter is the key that we can access the reducer by
Store.injectReducer('CounterReducer',CounterReducer)

injectReducer takes two parameters a key and the reducer

Use withDynamic builder

using withDynamic builder you can easily access your reducers and actions in your components

import withDynamic from './withDynamic';

function MyComponent() {
    return (
        <div>
            <legend>Hello there!</legend>
        </div>
    )
}

export default withDynamic(MyComponent)
                .injectAction('name', func)
                .injectReducer('CounterReducer')
                .build()

there are 3 main functions

injectAction which takes function name and the action and injects it into your component props

injectReducer which takes a reducer name and injcets it into your component props

build and at last build function which finalized the builder

dynamic-redux's People

Contributors

dependabot[bot] avatar nikandlv avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.