I'm refactoring some React code to have a more flexible approach.
- I have an abstract component that extends React.Component, let's say
class ATable extends React.Component
. - Another table extends this table like so:
class FooTable extends ATable
- Some other table does the same:
class BarTable extends ATable
- The (abstract) ATable component has a constructor method that provides bindings to other components:
ATable:
constructor(...args) {
super(...args);
this.components = {
tableHead: TableHead, // other (semi) abstract classes
tableBody: TableBody,
tableRow: TableRow,
(...)
}
}
render() {
<section>
<this.components.tableHead (...) />
(...)
</section>
}
- FooTable can override some of this.components to make components pluggable. This happens like this:
FooTable:
constructor(...args) {
super(...args);
this.components.tableHead: FooHead
}
}
class FooHead extends TableHead {} // FooHead <- TableHead <- React.Component
The goal is to make the table (which in reality is more complex) a pluggable system.
The issue here is that if the props of FooTable changes, render() events all the way down to TableHead are being called but no DOM updates are visible. Before the abstraction everything seemed to work OK.
How is this possible and how can I solve this?