React Daily

React Daily: Constructor Invocation Fix for ES6 Compatibility

A critical fix was merged to address TypeError issues when invoking class constructors without the 'new' keyword in JavaScript runtimes that don't support Reflect APIs, particularly affecting Hermes runtime.

Duration: PT1M40S

https://podlog.io/listen/react-daily-101f1abb/episode/react-daily-constructor-invocation-fix-for-es6-compatibility-2043161e

Transcript

Good morning, this is React Daily for May 14th, 2026.

Ruslan Lesiutin merged a fix for class component frame description that resolves constructor invocation issues in ES6 environments. The pull request addresses a TypeError that occurs when JavaScript runtimes without Reflect API support attempt to call class constructors without the 'new' keyword.

The problem was discovered in Hermes runtime, though it affects any JavaScript engine lacking Reflect implementation. Previously, React's fallback code used `fn.apply(Fake.prototype)` to invoke constructors, which violates ES6 requirements that mandate using the 'new' keyword for class constructors.

The solution replaces the incorrect invocation with a proper `new fn()` call, using a temporarily patched class prototype that traps the setter for the props object. This approach mirrors the existing strategy used when Reflect APIs are available, maintaining consistency across different runtime environments.

The fix spans four files, adding 105 lines and removing 16, with comprehensive test coverage to prevent regression. The changes are contained within React's component stack frame handling and development tools integration.

What's next: This fix improves React's compatibility across diverse JavaScript runtimes and strengthens error handling in development environments. The implementation provides a foundation for more robust constructor handling in future React versions.

That's your React Daily update. I'm back tomorrow with more development news.