redux-zero
Advanced tools
Changelog
4.3.1
This is now working for both TypeScript and JavaScript:
import { Provider } from "redux-zero/react";
Changelog
4.2.1
mapToProps
function optionalIf you don't pass mapToProps
function to connect
HOC or Connect
component, it will inject all state as props at the connected component.
const store = createStore({ message: "Hey" });
const App = connect()(({ message }) => <h1>{message}</h1>);
Changelog
4.2.0
Right now, actions must import an instance of the store in order to invoke setState()
, as discussed here. This version solved that problem. Now it's way easier to test the actions, because they are simply pure functions:
const createActions = store => ({
increment: state => ({ count: state.count + 1 })
});
const App = connect(mapToProps, createActions)(({ count, increment }) => (
<button onClick={increment}>{count}</button>
));
Changelog
4.1.1
connect
HOC and Connect
component provide the store as a propChangelog
4.1.0
Connect
component that can be used with a render callback as an alternative to the connect
HOCimport { Connect } from 'redux-zero/react'
// ...
render() {
return (
<Connect mapToProps={({ count }) => ({ count })}>
{({ count }) => <span>{count}</span>}
</Connect>
)
}
Changelog
4.0.0
Provider
and connect
from createStore
. With this we'll be able to build for different frameworks:import createStore from "redux-zero";
import { Provider, connect } from "redux-zero/react";
Changelog
3.0.0
unsubscribe
function from createStore. Now subscribe
returns unsubscribe
:const store = createStore();
const unsubscribe = store.subscribe();
unsubscribe();