React-dates: [IE10] `Cannot call a class as a function` console error

Created on 12 Sep 2018  路  5Comments  路  Source: airbnb/react-dates

I've made a simple demo app here: https://github.com/majapw/react-dates-demo/pull/3

It appears that our baseClass (https://github.com/airbnb/react-dates/blob/master/src/utils/baseClass.js) errors out in IE10 when an HOC-wrapped component extends it. It does not cause any problems when a non-wrapped component extends it.

to: @ljharb @noratarano @lencioni @AntiFish03

Most helpful comment

ugggghhhh. okay i'm going to revert the change and publish an 18.0.3 and then republish in 18.0.4 so that I can update our internals and we can WRITE A BABEL TRANSFORM I GUESS. :|

All 5 comments

The second commit (which inlines the check instead of double-extending) does not error out:
https://github.com/majapw/react-dates-demo/pull/3/commits/d79813cdf3a8576e954a9f0dee4ad8312bea9305

I believe this is because react-with-styles (along with almost every HOC) hoists statics, but does not preserve inheritance (https://github.com/airbnb/react-with-styles/blob/master/src/withStyles.jsx#L23-L33) - I don't think that's something that an HOC could or should reliably solve.

I think the solution is to find an ergonomic way to use the inlined implementation, rather than creating an inheritance hierarchy.

Is the only real answer to this a babel plugin? I've gone my whole life without writing a babel plugin and I was really hoping to maintain that streak.

I guess this could be a PureComponent polyfill of sorts? Does that make sense?

There's really these options:

  1. revert the change, and keep the manual sCU until we're ready to drop support for React < 15.3.
  2. drop support for React <15.3, and use PureComponent, and direct people to use a PureComponent polyfill (which would require us to locate/vet or create one)
  3. manually inline the gross code everywhere
  4. write a babel transform that converts PureComponents to the gross version, and then we can drop that transform when we want to drop support for React < 15.3 (and we could still recommend the polyfill for those people now)

ugggghhhh. okay i'm going to revert the change and publish an 18.0.3 and then republish in 18.0.4 so that I can update our internals and we can WRITE A BABEL TRANSFORM I GUESS. :|

Was this page helpful?
0 / 5 - 0 ratings

Related issues

easwee picture easwee  路  55Comments

igorescobar picture igorescobar  路  25Comments

Jucesr picture Jucesr  路  19Comments

ckeeney picture ckeeney  路  22Comments

isi-gach picture isi-gach  路  21Comments