@duckness/react-redux-pool
TypeScript icon, indicating that this package has built-in type declarations

1.0.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:

Package Sidebar

Install

npm i @duckness/react-redux-pool

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

10.6 kB

Total Files

6

Last publish

Collaborators

  • hitosu