Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Uncaught TypeError: cx is not a function in FelaTheme #497

Closed
filipmares opened this issue Nov 20, 2018 · 3 comments
Closed

Uncaught TypeError: cx is not a function in FelaTheme #497

filipmares opened this issue Nov 20, 2018 · 3 comments
Labels
vsts Paired with ticket in vsts

Comments

@filipmares
Copy link

Hi,

I'm trying to setup the Quick Start sample code and getting the runtime error below in the console. It looks to be related to the classnames import.

I've uploaded my source here in case i'm doing something totally wrong.

Any help getting up and running is greatly appreciated. Thanks!

renderComponent.js:94 Uncaught TypeError: cx is not a function
    at Object.render (renderComponent.js:94)
    at FelaTheme.render (FelaThemeFactory.js:49)
    at finishClassComponent (react-dom.development.js:14301)
    at updateClassComponent (react-dom.development.js:14264)
    at beginWork (react-dom.development.js:15082)
    at performUnitOfWork (react-dom.development.js:17820)
    at workLoop (react-dom.development.js:17860)
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:199)
    at invokeGuardedCallback (react-dom.development.js:256)
react-dom.development.js:15749 The above error occurred in the <FelaTheme> component:
    in FelaTheme (created by Button)
    in Button
    in Unknown
    in ThemeProvider (created by FelaTheme)
    in Provider (created by FelaTheme)
    in FelaTheme (created by ProviderConsumer)
    in ProviderConsumer (created by Provider)
    in Provider

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
logCapturedError @ react-dom.development.js:15749
react-dom.development.js:18807 Uncaught TypeError: cx is not a function
    at Object.render (renderComponent.js:94)
    at FelaTheme.render (FelaThemeFactory.js:49)
    at finishClassComponent (react-dom.development.js:14301)
    at updateClassComponent (react-dom.development.js:14264)
    at beginWork (react-dom.development.js:15082)
    at performUnitOfWork (react-dom.development.js:17820)
    at workLoop (react-dom.development.js:17860)
    at renderRoot (react-dom.development.js:17946)
    at performWorkOnRoot (react-dom.development.js:18837)
    at performWork (react-dom.development.js:18749)
@pkumarie2011 pkumarie2011 added the vsts Paired with ticket in vsts label Nov 20, 2018
@miroslavstastny
Copy link
Member

The problem is the different result between webpack and parceljs in handling following import:

import * as cx from 'classnames'

In webpack cx ends up being a function, in parceljs it is an object with default property being that function:
image

Not sure if it is a problem in (a) the import statement, (b) classnames package or (c) parceljs.

@filipmares
Copy link
Author

@miroslavstastny You're right! Switch to webpack and it seems to resolve. I will update the repo. Thanks!

@layershifter
Copy link
Member

@filipmares FYI: we fixed this in #570 👍

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

No branches or pull requests

4 participants