I'm working with react-table in the latest version 6.10.3 they have renamed the deprecated methods by adding the UNKOWN prefix (https://github.com/tannerlinsley/react-table/pull/1461). However when working with Peact X and preact/compat these functions are not being called.
Should preact/compat patch the unsafe functions on Component?
This https://github.com/preactjs/preact/blob/master/compat/src/index.js#L368 seems to patch the functions on the Component.
In this issue https://github.com/preactjs/preact/issues/1461 you mention keeping them until they are removed from react. Does Preact X with preact/compat support the UNSAFE* functions ?
Yes preact/compat does support all the UNSAFE_* lifecycle hooks. Can you share a repo/codesandbox where those are not executed for you? Just checked locally and they are called as expected.
Here is an example of react-table failing https://codesandbox.io/s/cranky-architecture-gibye?fontsize=14. This error is due to the UNSAFE_componentWillMount function not being called before render.
I have no fix yet, but I found the root cause of this issue. We add support for UNSAFE_* lifecycles by setting up a getter/setter and pointing them to the unprefixed variants via Object.defineProperty. So far so good.
Trouble is that this breaks when a third-party library like react-table overwrites that via Object.defineProperty. This is not specific to react-table but happens for other libraries which use some form of inheritance. That's because babel transpiles down class components via lots of Object.defineProperty calls.
Most helpful comment
I have no fix yet, but I found the root cause of this issue. We add support for
UNSAFE_*lifecycles by setting up agetter/setterand pointing them to the unprefixed variants viaObject.defineProperty. So far so good.Trouble is that this breaks when a third-party library like
react-tableoverwrites that viaObject.defineProperty. This is not specific toreact-tablebut happens for other libraries which use some form of inheritance. That's because babel transpiles down class components via lots ofObject.definePropertycalls.