I have followed your method for inheritance inversion and I don’t understand why you can’t simply…
Terence Chow
1

  • it’s not the standard render signature so that might give some problems with compatibility with React standard. Remember that render is a special method used by react
  • props are immutable objects so you cannot modify them so when you need to change the props of an element such as the returned by render, then you need to clone that element and pass new props.

Remember that there’s a distinction between a Component such as function MyComponent(props) {} and the element<MyComponent/> , see the quoted post by Dan Abramov about the difference between components and elements. But basically elements are frozen representation of a Component render output, children and props. So you can only change that element by cloning it.

Like what you read? Give franleplant a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.