Closed
Description
We are using an alternative ReactClass API internally, and I think it should be considered for upstream.
https://gist.github.com/natefaubion/c639440f2fafd079c5d4eb36012d8e0e
It's basically the module pattern, but has several notable improvements:
- It doesn't use
create-react-class
which is unsupported and has lots of unnecessary machinery - It's more flexible (we can allocate mutable cells, which gives us instance state, and obviates the need for custom ref handling and effects)
- It's more efficient (we don't have to rebind event handlers on every render)
- It forces you to use safe props (only records, no overwritten "key" or "children" props)
- It uses
Union
for calculating the available lifecycle fields, so there's no need for special-casingcomponentDidCatch
(only provide the ones you need). - It exposes
PureComponent
, and disallowsshouldComponentUpdate
in that case. - It's more amenable to abstraction since you get the
ReactThis
reference up front in the constructor, and you don't need to pass it around everywhere.
Metadata
Metadata
Assignees
Labels
No labels