reactjs - How to alter render method when composing react component -
i want extend functionality of component third party react library. officially recommended use composition on inheritance. (composition-vs-inheritance). however, examples found composition , hoc add existing component (create entire instance of wrapped component part of render()), never alter it. wonder how 1 implement following use case:
i have tree component hosts multiple instances of treenode component. want implement treenodewithcontent renders additional content part of itself. render method of treenode looks that:
public render() { return <div> <div>{this.rendertop()}</div> <div>{this.renderbottom()}</div> </div>
i want render additional content in between top , bottom. hence higher order component doesn't work, it?!
furthermore, i'd need treewithcontent component same tree, hosting instances of treenodewithcontent rather treenode. tree has render method calls private method in treenodes created. again, don't see how make tiny change without copying entire code tree?
Comments
Post a Comment