Coder Social home page Coder Social logo

redux-bundler-hook's Introduction

Redux-Bundler Hook

CircleCI

React.js bindings to Henrik Joreteg's redux-bundler.

See redux-bundler documentation at https://reduxbundler.com/

Installation

npm install redux-bundler-hook

Usage

wrap your React app with a provider

import { hydrate } from 'react-dom'
import { ReduxBundlerProvider } from 'redux-bundler-hook'

import createStore from '../bundles'

const store = createStore()

hydrate(
  <ReduxBundlerProvider store={store}>
    <App />
  </ReduxBundlerProvider>,
  document.getElementById('root')
)

use the hook in your components

import { useConnect } from 'redux-bundler-hook'

import AppLayout from './AppLayout'

export default function App() {
  const {
    route: { component: RoutedComponent },
    colorScheme,
    doSetColorScheme,
  } = useConnect('selectRoute', 'selectColorScheme', 'doSetColorScheme')

  return (
    <AppLayout>
      <RoutedComponent colorScheme={colorScheme} onSetColorScheme={doSetColorScheme} />
    </AppLayout>
  )
}

In cases you need a store itself down your component tree, this package also exports useReduxBundlerStore hook that will return the store.

redux-bundler-hook's People

Contributors

abuinitski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

israelite7

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.