Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

update to v0.25.0 leads to "Uncaught TypeError: Cannot call a class as a function" #488

Closed
barbalex opened this issue Aug 21, 2017 · 4 comments

Comments

@barbalex
Copy link

When I update from v0.24.0 to v0.25.0 my app breaks with above error.

Here is the output in the console:

main.9d27d69f.js:72780 Uncaught TypeError: Cannot call a class as a function
    at r (main.9d27d69f.js:72780)
    at t (main.9d27d69f.js:72780)
    at a (createEagerElementUtil.js:16)
    at createEagerFactory.js:18
    at u.render (withState.js:60)
    at f._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:798)
    at f._renderValidatedComponent (ReactCompositeComponent.js:821)
    at f.performInitialMount (ReactCompositeComponent.js:361)
    at f.mountComponent (ReactCompositeComponent.js:257)
    at Object.mountComponent (ReactReconciler.js:45)
r	@	main.9d27d69f.js:72780
t	@	main.9d27d69f.js:72780
a	@	createEagerElementUtil.js:16
(anonymous)	@	createEagerFactory.js:18
u.render	@	withState.js:60
_renderValidatedComponentWithoutOwnerOrContext	@	ReactCompositeComponent.js:798
_renderValidatedComponent	@	ReactCompositeComponent.js:821
performInitialMount	@	ReactCompositeComponent.js:361
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
mountChildren	@	ReactMultiChild.js:236
_createInitialChildren	@	ReactDOMComponent.js:703
mountComponent	@	ReactDOMComponent.js:522
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
performInitialMount	@	ReactCompositeComponent.js:370
mountComponent	@	ReactCompositeComponent.js:257
mountComponent	@	ReactReconciler.js:45
a	@	ReactMount.js:104
perform	@	Transaction.js:143
s	@	ReactMount.js:126
perform	@	Transaction.js:143
batchedUpdates	@	ReactDefaultBatchingStrategy.js:62
i	@	ReactUpdates.js:97
_renderNewRootComponent	@	ReactMount.js:319
_renderSubtreeIntoContainer	@	ReactMount.js:401
render	@	ReactMount.js:422
(anonymous)	@	index.js:68
t	@	bootstrap 212a8f5…:49
(anonymous)	@	main.9d27d69f.js:38090
t	@	bootstrap 212a8f5…:49
(anonymous)	@	bootstrap 212a8f5…:144
(anonymous)	@	bootstrap 212a8f5…:144

This only happens in production, not in dev mode.

Here is my app: https://github.com/barbalex/brexit

@oliviertassinari
Copy link
Contributor

This issue could be linked to #473. (I still don't get why the change was made).

@istarkov
Copy link
Contributor

Duplicate of #489

@istarkov istarkov marked this as a duplicate of #489 Aug 23, 2017
@barbalex
Copy link
Author

barbalex commented Aug 23, 2017

I changed the render = () => calls now and hope that production will work.

If I remember right, it is not necessary (as in other functions inside a class) because render binds this (please correct me if this is wrong).
But is there anything saying that binding a render function is wrong?

There are a number of blogs telling to bind this in above way. So I guess I won't be the last to bump into this behaviour.

And I feel that this behavior is very bad as it breaks an app only in production. It really bit me hard.

@istarkov
Copy link
Contributor

We had the same issue in the past but with more rare case. As I wrote in related issue it will be good to provide additional checks at dev mode, it can be a good first PR ;-)
About render, Having that there is no documented way to check that something is react class we used undocumented method, and in latest release changed to 'duck typing' check method, both are bad, but latest allows users of Preact and Inferno to use recompose. We are open to better ideas.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants