@duckness/react-redux-pool

    0.9.0 • Public • Published

    @duckness/react-redux-pool

    @duckness/pool + React-Redux

    NPM License Libraries.io dependency status for latest release, scoped npm package GitHub issues vulnerabilities npm bundle size

    Example

    import React, { Suspense } from 'react'
    import ReactDOM from 'react-dom'
    import Pool from '@duckness/pool'
    import ReactReduxPool from '@duckness/react-redux-pool'
    
    import CounterDuck from './ducks/CounterDuck'
    
    const App = React.lazy(() => import('./components/App'))
    
    function RootComponent() {
      return (
        <Suspense fallback="Loading...">
          <App />
        </Suspense>
      )
    }
    
    const CounterPool = ReactReduxPool(
      Pool({
        buildStore: ({ initialCounter = 0 } = {}) => {
          return { counter: initialCounter }
        }
      }),
      RootComponent
    )
    CounterPool.addDuck(CounterDuck)
    
    ReactDOM.render(CounterPool.render(), document.getElementById('counterApp'))

    Table of Contents

    API

    Create ReactReduxPool

    const myPool = ReactReduxPool(
      pool, // @duckness/pool to use with React
      renderRootComponent // root component
    )

    .render()

    Return root component wrapped in Redux <Provider>. Render will build pool store if store was not built.

    myPool.render()
    // => <Provider store={pool.store}>{renderRoot(pool.props)}</Provider>

    Pool methods

    ReactReduxPool forward Pool calls to included Pool

    const myPool = Pool()
    const myReactReduxPool = ReactReduxPool(myPool, () => null)
    
    myReactReduxPool.addDuck
    // => myPool.addDuck
    myReactReduxPool.build
    // => myPool.build
    myReactReduxPool.store
    // => myPool.store
    myReactReduxPool.setErrorReporter
    // => myPool.setErrorReporter

    Examples

    https://github.com/hitosu/duckness/tree/master/stories

    @Duckness packages:

    Install

    npm i @duckness/react-redux-pool

    DownloadsWeekly Downloads

    34

    Version

    0.9.0

    License

    MIT

    Unpacked Size

    9.82 kB

    Total Files

    5

    Last publish

    Collaborators

    • hitosu