Closed vko-online closed 5 years ago
Hello, You can write your actions and your components separately and use connect to do the coupling,
import { connect } from 'unistore/preact';
const YourBaseElement = ({ storeparams, yourAction }) => <div>...</div>
const YourElement = connect(
(state) => ({
// you can deconstruct what parameters are passed to your element
// or just pass state to do the deconstruction in the component prototype
}),
(state, props) => ({
yourAction: yourActionFunc
})
)(YourBaseElement);
You can then test your action as any functions,
I hope I've properly answered to your question :)
Isn't this library coupling logic with component? (Which we try to avoid, and use redux) Also its not testable? (As actions are reducers, which are coupled to component)