Registry / web-framework / redux-bundler-preact

redux-bundler-preact

JSON →
library2.0.1jsnpmunverified

Redux-bundler-preact provides essential bindings to integrate redux-bundler with Preact applications. It offers a `Provider` component to make the redux-bundler store available via context and a `connect` higher-order component for mapping selectors and action creators to component props. The current stable version is 2.0.1, which targets Preact versions 10.0.0 and above. Earlier Preact versions (v3-8) require installing redux-bundler-preact v1. Releases are typically tied to major Preact version updates or critical bug fixes, as seen with the 2.0.0 upgrade for Preact X. A key differentiator is its `connect` API, which accepts string names for selectors and action creators, departing from the typical function-based mapStateToProps/mapDispatchToProps patterns found in other Redux bindings, offering improved performance characteristics where diffing happens outside the component itself.

npm install redux-bundler-preact
INSTALL
IMPORT
SIG · REDUX-BUNDLER-PREA
R
redux-bundler-preact
web-frameworkjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Provider
import { Provider } from 'redux-bundler-preact'
const { Provider } = require('redux-bundler-preact')
The library primarily uses ES Module syntax in examples. Provider should be used once at the root of your Preact application to pass the Redux-Bundler store via context.
connect
import { connect } from 'redux-bundler-preact'
const connect = require('redux-bundler-preact').connect
Connect is a higher-order component. It takes string names of selectors and action creators as arguments, followed by the component to wrap. This differs from typical `react-redux` usage.

This example demonstrates how to set up the `Provider` at the application root with a Redux-Bundler store and how to `connect` a component to specific selectors and action creators using their string names.

import { connect, Provider } from 'redux-bundler-preact'; import { h } from 'preact'; // Required for JSX in Preact, ensure this is in scope // Assume './bundles' exports a function that returns a redux-bundler store // For this example, we'll create a dummy store. const getStore = () => ({ getState: () => ({ myValue: 'Initial Value', myOtherValue: 'Another Value' }), subscribe: () => () => {}, dispatch: (action) => console.log('Dispatching action:', action) }); // Example AppRoot component that receives props from connect const AppRoot = ({ myValue, myOtherValue, doInitiateSignIn }) => ( <div style={{ padding: '20px', border: '1px solid #ddd', borderRadius: '4px' }}> <h1>Redux-Bundler Preact Example</h1> <p>My Value: <strong>{myValue}</strong></p> <p>My Other Value: <strong>{myOtherValue}</strong></p> <button onClick={doInitiateSignIn} style={{ padding: '10px 15px', backgroundColor: '#007bff', color: 'white', border: 'none', borderRadius: '4px', cursor: 'pointer' }}> Initiate Sign In </button> </div> ); // Connect the AppRoot component to specific selectors and action creators const ConnectedAppRoot = connect( 'selectMyValue', // Placeholder selector name 'selectMyOtherValue', // Placeholder selector name 'doInitiateSignIn', // Placeholder action creator name AppRoot ); // Render the application with the Provider at the root export default () => ( <Provider store={getStore()}> <ConnectedAppRoot /> </Provider> );
Debug
Known issues
breakingVersion 2.0.0 of `redux-bundler-preact` introduced a breaking change by upgrading its peer dependency to support Preact 10.x. Older Preact versions (v3-8) are incompatible with `redux-bundler-preact` v2.
fix
If using Preact >=10.0.0, install `redux-bundler-preact`. For Preact v3-8, you must install `redux-bundler-preact@^1`.
affects: >=2.0.0
gotchaThe `connect` HOC expects string names for selectors and action creators. If a specified string name does not correspond to an existing selector or action creator in your Redux-Bundler store, it will result in a runtime error.
fix
Always meticulously verify the string names passed to `connect()` against your Redux-Bundler's defined selectors and action creators. Typographical errors are a common source of these runtime issues.
affects: >=1.0.0
Errors
Common errors & fixes
Error: redux-bundler-preact: selector 'nonExistentSelector' does not exist.
You have provided a string name to the `connect()` HOC that does not match any available selector or action creator exported by your Redux-Bundler instance.
fix
Carefully check the spelling and ensure the existence of all selector and action creator names passed as strings to `connect()`. Confirm that your Redux-Bundler bundles correctly export these members.
TypeError: Cannot read properties of undefined (reading 'getState') in Provider component
The `store` prop passed to the `Provider` component is either undefined or not a valid Redux-Bundler store object, which must implement `getState`, `subscribe`, and `dispatch`.
fix
Ensure that the function or variable supplying your Redux-Bundler store to the `Provider` (e.g., `getStore()` in examples) correctly returns an initialized and valid store instance.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
preactrequiredPeer dependency for rendering components; version 2.x requires Preact >=10.0.0. Incompatible Preact versions will lead to runtime errors.
Agent activity
2 hits · last 30 days
node
2
Resources
redux-bundler-preact — npm install redux-bundler-preact · libregistry