ownProps undefined in actions using redux-zero/preact
opened this issue · comments
import {h} from 'preact'
import createStore from 'redux-zero'
import {Provider, connect} from 'redux-zero/preact'
const Component = ({ count, increment }) => <h1 onClick={() => increment()}>{count}</h1>;
const mapToProps = ({ count }) => ({ count });
const actions = (store, ownProps) => ({
increment: state => {
console.log(ownProps) // === undefined
return ({ count: state.count + ownProps.value})
}
});
const ConnectedComponent = connect(mapToProps, actions)(Component);
const store = createStore({ count: 1 });
export default () => (
<Provider store={store}>
<ConnectedComponent value={10} />
</Provider>
);
In preact/Connect, I belive this.props should be passed as third argument to bindActions in the getActions function (line 23)
@chanthafef thanks for noticing this. We added ownProps
to react bindings but we forget about preact's one.
I'll be more than happy to accept a PR on this.
Thanks again.
Thanks for the fast answer. --> PR