-
Notifications
You must be signed in to change notification settings - Fork 58
Some way to add custom Actions #40
Comments
I think the first implementation is OK, and you can use decorator to make that look more concise. |
If anybody is interested I've cleaned up my implementation and this is what I finally ended up with. const uiConfig = {
key: 'my-custom-config',
state: {
// ...
},
reducer: (state, action) => {
// ...
},
mapStateToProps: (state, props) => {
// ...
},
mapDispatchToProps: {
// ...
}
};
export class MyCustomComponent extends Reactive.Component {
// ...
}
export default connect(uiConfig.mapStateToProps, uiConfig.mapDispatchToProps)(ui(uiConfig)(MyCustomComponent));
// ...
// in our implementation this line looks like this with custom connect wrapper.
export default connect(uiConfig)(MyCustomComponent); We decided we would keep all the config at top to make it easier to read/modify the code. @codering I actually don't like using decorator since there is no way to export the non decorated version. In my project we use the non decorated class to create a page with all the components on a single page to validate and test each component. Like a manual unit test page for components. |
You can also check out https://github.com/gcazaciuc/redux-fractal which allows you to inject props dispatching custom actions. |
Currently I'm doing the following to add custom action to my component.
This feels wrong as I'm double wrapping the Component. Is there a better way to do this?
or another implementation would be...
I think what I want is something like the following.
The text was updated successfully, but these errors were encountered: