Should we add support for the class-based Component API?
This could also be implemented as a separate package - and, interestingly, would work with React/Preact as well, enabling them to use hooks in render-methods too.
Here's a working prototype:
https://codesandbox.io/s/fre-component-i6sbs
For now, the prototype requires manually calling a useComponent function to wrap a Component subclass to a function using only hooks. (We might consider integrating this in the h function, where you could check if e.g. type.prototype.render is present, which it is on Component subclasses, but isn't on functional components.)
Features supported so far:
Should we add support for the class-based
ComponentAPI?This could also be implemented as a separate package - and, interestingly, would work with React/Preact as well, enabling them to use hooks in render-methods too.
Here's a working prototype:
https://codesandbox.io/s/fre-component-i6sbs
For now, the prototype requires manually calling a
useComponentfunction to wrap a Component subclass to a function using only hooks. (We might consider integrating this in thehfunction, where you could check if e.g.type.prototype.renderis present, which it is on Component subclasses, but isn't on functional components.)Features supported so far:
constructor(props)componentDidMount()componentWillUnmount()propsstaterender()forceUpdate()static defaultPropsstatic displayNamesetState(state, callback)setState(function, callback)shouldComponentUpdate(nextProps, nextState)componentDidUpdate(prevProps, prevState, snapshot)static getDerivedStateFromProps(props, state)static getDerivedStateFromError(error)componentDidCatch(error, info)getSnapshotBeforeUpdate(prevProps, prevState)