re: React Beginner Question Thread ⚛ VIEW POST

VIEW FULL DISCUSSION
 

Hey Dan,
Thanks for this thread it already answered few of my questions!

Where I work we do separation of container and presentational components, sometimes when we do customization to components which is mostly container components I have to override methods in order for the customization to work. What I mean is that if I created component A that extends React.component, I will extend B from A and impelment the method I wish to override. I know that the react team discourage inheritance and we do use component composition but in the case i described looks suitable for a container component. What are your thoughts on this scenario?
Thanks!

 

We explicitly discourage it and will continue to. Your use case is solvable by composition just fine. Instead of overriding methods, have the “base” components take those functions as props. Then have the “concrete” components render it and pass their implementations of these methods.

code of conduct - report abuse