- Renaming
UNSAFE_componentWillUnmount
tocomponentWillUnmount
- Update
bindActions
types to preserve argument types in TypeScript
- Update Action type to support promise returning actions in TypeScript
- Removing React class method warnings
- Added ComponentProps concept and updated connect method type signature to accept generic type for ComponentProps so that type safety works when a connected component is used.
- Fix to make sure React's
connect()
components rerender when their props change.
- Fixed missing types/Actions in the final bundle
- Added hooks for react >= 16.8.0. The react bindings now offer a
useStore
,useSelector
anduseAction
hooks.
const Counter = () => {
const store = useStore();
const count = useSelector(({ count }) => count);
const incrementBy = useAction(({ count }, value) => ({
count: count + value
}));
return (
<>
<p>Value: {count}</p>
<button onClick={() => incrementBy(10)}>10 More</button>
</>
);
};
- Fixed connect in preact bindings to call the
mapStateToProps
function when the component props change, not just when the state store changes
- Changing from
npm
toyarn
- Added Actions typings for writing typesafe React components
- Fixed Provider and connect in preact biddings so they now work for Preact X
- Added Redux-Devtools options params
BREAKING CHANGES
- Add generics to
bindActions()
,connect()
,createStore()
,Provider
,Store
. - Default: any
note: If using createStore() with partial initial state, it will inferred to incorrect type.
import createStore from "redux-zero";
interface ReduxState {
a: number;
b: number;
}
const store = createStore({ a: 3 }); // Store<{a: 3}>
const store = createStore<ReduxState>({ a: 3 }); // Store<Partial<ReduxState>>
const store = createStore<ReduxState>({ a: 3, b: 3 }); // Store<ReduxState>
- Improved
reset
function on the store, now it makes reset toinitialState
- Fixed
devtoolsMiddleware
imports
- Simplify createStore function to improve minimization
- Added ownprops to preact actions
- Added ownprops as optional argument to the actions creator
- Better typing support
- Fix deps with npm audit
- Add typescript 3 support
- Reverting 4.13.3
- React
connect
high order component now propagate connected component statics
- Adding some typings
- Adding protection to
window
for SSR on devtools
- Adding
reset
function to the store
- Pass action
args
to middleware and devtools
- Add
combineActions
function
import { combineActions } from "redux-zero/utils";
- Fix bug of devtools middleware - handle async actions
- Implement connect HOC decorator for preact
- Add hot module reloading support to React
connect()
decorator
- Disable generation of source maps
- Add DevTools middleware
- Fix a bug of middleware
- Add bindActions export
import { bindActions } from "redux-zero/utils";
- Add Vue.js bindings
- Adds middleware support:
// a middleware
const logger = store => next => action => {
console.log("current state", store.getState());
return next(action);
};
// compose middlewares
const middlewares = applyMiddleware(logger, anotherMiddleware);
const store = createStore({}, middlewares);
- Fixes bug in which ownProps were not being passed as the second argument to mapToProps inside a connect HOC
- Shallow clone mutated object and array in Svelte bindig
- Adds Thennable actions. Now we can declare actions as so:
const mapActions = ({ setState }) => ({
getTodos() {
setState({ loading: true });
return client
.get("/todos")
.then(payload => ({ payload, loading: false }))
.catch(error => ({ error, loading: false }));
}
});
- Removing peerDependencies from
package.json
- Fix typings, remove unsubscribe from Store interface since isn't used
[info] Using redux-zero along with TypeScript gives an error when implementing:
<Provider store={store}><Whatever/></Provider>
due to the actual store object
and the expected attribute differ.
- Added Store interface as signature for createStore function.
- Fixes Svelte connect function date object change detection
- Add Preact bindings
- Fixes binding imports with TypeScript
This is now working for both TypeScript and JavaScript:
import { Provider } from "redux-zero/react";
- Add connect function for Svelte and usage example.
- Let
mapToProps
function optional
If 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>);
- Binding actions instead of coupling them to the store.
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>
));
- Fixes drawback from the latest release by making
connect
HOC andConnect
component provide the store as a prop
- Include
Connect
component that can be used with a render callback as an alternative to theconnect
HOC
import { Connect } from 'redux-zero/react'
// ...
render() {
return (
<Connect mapToProps={({ count }) => ({ count })}>
{({ count }) => <span>{count}</span>}
</Connect>
)
}
- Fixed bug where unsubscribing a listener made listeners ahead be also removed.
- Separating
Provider
andconnect
fromcreateStore
. With this we'll be able to build for different frameworks:
import createStore from "redux-zero";
import { Provider, connect } from "redux-zero/react";
- Removing
unsubscribe
function from createStore. Nowsubscribe
returnsunsubscribe
:
const store = createStore();
const unsubscribe = store.subscribe();
unsubscribe();
- Now you can pass a function to
setState
. Example:
store.setState(state => {
return {
counter: state.counter + 1,
changed: true
};
});
- Changing Provider API to accept store as a prop instead of context.
- Removing PropTypes