
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
react-redux-simple
Advanced tools
An alternative way to connect React components to a Redux store.
import React from "react";
import { connect } from "react-redux-simple";
import * as selectors from "./selectors";
import * as actions from "./actions";
class Counter extends React.Component {
static selectors = {
count: selectors.getCount
}
static actions = {
inc: actions.increment,
dec: actions.decrement
}
render() {
let { count, inc, dec } = this.props;
return (
<div>
<button onClick={dec}>-</button>
<span>{count}</span>
<button onClick={inc}>+</button>
</div>
);
}
}
export default connect(Counter)
Or with a functional component:
const Counter = ({ count, inc, dec }) => (
<div>
<button onClick={dec}>-</button>
<span>{count}</span>
<button onClick={inc}></button>
</div>
);
Counter.selectors = {
count: selectors.getCount
};
Counter.actions = {
inc: actions.increment,
dec: actions.decrement
};
export default connect(Counter)
You'll need to install both this package and react-redux
:
npm install react-redux react-redux-simple
An optional mapping of prop names to selectors (a function which takes the state and returns a value).
static selectors = {
count: state => state.count
}
If your selectors depend on the components own props, then selectors
can be a function instead.
static selectors = props => ({
count: state => state.count * props.multiplier
})
A common pattern is to name your selectors and group them in their own file (or colocate them with reducers).
import * as ToolSelectors from "./selectors/tool";
import * as ViewSelectors from "./selectors/view";
class Artboard extends Component {
static selectors = {
tool: ToolSelectors.getCurrentTool,
width: ViewSelectors.getVisibleWidth,
height: ViewSelectors.getVisibleHeight
};
}
An optional mapping of prop names to action creators (a function which returns an action).
static actions = {
increment: amount => ({ type: "INCREMENT", amount })
}
Another common pattern is to name and group actions in related files, then import them into the components that need them.
import * as ToolActions from "./actions/tool";
import * as ViewActions from "./actions/view";
class Artboard extends Component {
static actions = {
setTool: ToolActions.setCurrentTool,
setWidth: ViewActions.setVisibleWidth,
setHeight: ViewActions.setVisibleHeight
};
}
<Provide />
?You still need to make sure that your components have access to the store. The easiest way to do this is to have a <Provide />
component at the root
of your component tree.
import { Provide } from "react-redux"; // or from "react-redux-simple";
ReactDOM.render(
<Provide store={myStore}>
<App />
</Provide>
);
mergeProps
and options
?This is designed to be a stupidly simple wrapper, if you need more control you can just use the React-Redux version of connect
for a component with specific needs.
FAQs
A selector friendly shortcut for React-Redux
The npm package react-redux-simple receives a total of 41 weekly downloads. As such, react-redux-simple popularity was classified as not popular.
We found that react-redux-simple demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.