Below is a component of a higher order. The HOC connects to the shorthand specifically for access to one of the creators of the action: importantReduxAction .
function withExtraStuff (InnerComponent) { return class Enhancer extends React.Component { constructor(props){ super(props) this.importantMethod = this.importantMethod.bind(this) } importantMethod(){
This is a wrapped component that will use the HOC component. It also connects to the shorthand to access another method: otherReduxAction .
class ChildComponent extends React.Component { constructor(props){ super(props) this.doImportantThing = this.doImportantThing.bind(this) } doImportantThing(){
The problem is that my mapDispatchToProps inside my HOC is overwritten by the child, and the action creator: importantReduxAction never passed to my HOC. It receives an error message:
undefined method
I solved this by passing the method to my child component as follows:
let mapDispatchToProps = (dispatch)=>{ return bindActionCreators({otherReduxAction, importantReduxAction}, dispatch) }
But this solution is actually not the way I want everything to work. Is there a way for my HOC to integrate in the action creators that he wants to use with those that were associated with the wrapped component? Or will I have to find a new way?
TL; DR: HOC The component that uses the action creator wraps a child component that also has it. The creator of the HOC-action receives a blow to curb and never passed.
source share