Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Object(...) is not a function - @emotion #4796

Closed
theiliad opened this issue Nov 15, 2018 · 45 comments
Closed

Uncaught TypeError: Object(...) is not a function - @emotion #4796

theiliad opened this issue Nov 15, 2018 · 45 comments

Comments

@theiliad
Copy link

Describe the bug
When updating @storybook/react to 4.0.7, we are receiving the following error:

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/IBM/carbon-charts
  2. Update @storybook/react version in packages/react/package.json to 4.0.7
  3. Run npm install on the root folder of the repo
  4. Run npm run storybook in packages/react
@shilman
Copy link
Member

shilman commented Nov 16, 2018

https://github.com/storybooks/storybook/blob/next/MIGRATION.md#react-163

Please upgrade to React 16.3+ and this problem should go away. We hope to re-introduce support for older versions of React in Storybook 4.1 coming soon.

@shilman shilman closed this as completed Nov 16, 2018
@theiliad
Copy link
Author

Working again, thanks 👍

@magicspon
Copy link

I'm seeing this issue.

Using react 16.6.3,
@storybook/react 4.0.9
and @emotion/core 10.0.0

cheers

@psabharwal123
Copy link

i am using preact instead of react, what changes are required in preact to make this work (basically what is the specific change from old react to 16.3+), also should i open a new bug?

@MarcNq
Copy link

MarcNq commented Nov 29, 2018

Also seeing this issue when trying to use emotion for my own components.

Using:
React 16.3.2 + @storybook/react 4.0.2
React 16.6.3 + @storybook/react 4.0.2
React 16.6.3 + @storybook/react 4.0.9
And @emotion/core 10.0.0 in all cases.

@aimuzov
Copy link

aimuzov commented Dec 4, 2018

I'm seeing this issue.

Using react 16.7.0-alpha.2,
@storybook/4.1.0-alpha.10
and @emotion/core 10.0.1

cheers

UPD:
same problem with:
@storybook/4.1.0-alpha.11

@nullobject
Copy link

I'm seeing this issue too:

react 16.6.3
@storybook/react 4.0.7

nullobject pushed a commit to conversation/ui that referenced this issue Dec 7, 2018
There was an issue where it caused storybook compilation issues. For more info: storybookjs/storybook#4796
@sievan
Copy link

sievan commented Dec 11, 2018

I'm also seeing this issue

react 16.6.3
@storybook/react 4.0.7
@emotion/core 10.0.4

@ysgk
Copy link

ysgk commented Dec 12, 2018

I had the same problem.

  • react 16.6.3
  • @storybook/react 4.0.12
  • @storybook/addon-knobs 4.0.12
  • @emotion/core 10.0.4
  • @emotion/styled 10.0.4

After all, I downgraded emotion to 0.x.x and it's working fine now.

  • @emotion/core 0.13.1
  • @emotion/styled 0.10.6

I should have taken the warning message 😅

warning "@storybook/addon-knobs > @emotion/styled > @emotion/styled-base@0.10.6" has incorrect peer dependency "@emotion/core@0.x.x".

@igor-dv
Copy link
Member

igor-dv commented Dec 12, 2018

Linking the #4925 pr for reference.

@devictoribero
Copy link

devictoribero commented Dec 15, 2018

I have:

"@emotion/core": "^10.0.5",
"@emotion/styled": "^10.0.5",
"@storybook/react": "^4.1.1",
"react": "^16.5.1",
"react-dom": "^16.5.1"

And it's not working either. 😢

@diegopamio
Copy link

Any clue on how to overcome this? I'd gladly try to fix it, but I'm not certain if I would be able to do it.

@devictoribero
Copy link

@diegopamio I tried but I could not 😢

@sievan
Copy link

sievan commented Dec 20, 2018

@diegopamio Only fix I could find was to downgrade (as @ysgk mentioned) to:

  • @emotion/core 0.13.1
  • @emotion/styled 0.10.6

@MarcNq
Copy link

MarcNq commented Dec 20, 2018

I think what should be done is upgrading Storybook's Emotion to last version, but I'm not sure how could that affect to people using prior versions of Emotion, or whether that is relevant for Storybook's authors. After all, retrocompatibility can be like being flatmates with an ex.

For the ones who are looking for a nice alternative:
I recommend using Fela instead of Emotion. It's a nice library that supports the same syntax as Emotion, and more. That obviously solves the issue.

@sievan
Copy link

sievan commented Dec 21, 2018

@MarcNq This seems to be happening already 😄 #4525

@agutoli
Copy link

agutoli commented Dec 21, 2018

I just installed @emotion/core 0.13.1 and added a resolver at webpack to force use this version.

It's working for me.

module.exports = {
  plugins: [
    // your custom plugins
  ],
  module: {
    rules: [
      // add your custom rules.
    ],
  },
  resolve: {
    alias: {
      "emotion": path.resolve(__dirname, 'node_modules/@emotion')
    }
  }
};

node: v8.11.1
npm: 5.10.0
@storybook/addon-actions: 4.0.0
@storybook/addon-links: 4.0.0
@storybook/addons: 4.0.0
@storybook/react: 4.0.0

@slikts
Copy link

slikts commented Dec 30, 2018

This should not be closed; I'm using React 16.7 and getting the same error.

@slikts
Copy link

slikts commented Dec 30, 2018

I fixed this for myself by downgrading to Storybook 3.

@farcaller
Copy link

That's not a "fix", it's a workaround at most. The issue needs to be addressed.

@igor-dv
Copy link
Member

igor-dv commented Dec 31, 2018

This issue is being addressed as mentioned in the previous comments.

@igor-dv igor-dv reopened this Dec 31, 2018
@vjpr
Copy link

vjpr commented Jan 22, 2019

Just realized v5 alpha is out and it works for me. Should this issue be closed.

@shilman
Copy link
Member

shilman commented Jan 23, 2019

Sorry, forgot to comment on this issue. v5 is in alpha on the next NPM tag. Here's the latest alpha: https://github.com/storybooks/storybook/releases/tag/v5.0.0-alpha.8

Upgrade today to try it out. We're hoping to progress to RC by next week!

@shilman shilman closed this as completed Jan 23, 2019
@ahmadalfy
Copy link

Can confirm upgrading to storyboard 5.0.0-RC1 fixed it

@Rolandisimo
Copy link

Rolandisimo commented Feb 18, 2019

Also, ran into an issue throwing Uncaught TypeError: Object(...) is not a function on a CRA2 build.
Nothing worked until I tried the 5.0.0-alpha version of @storybook/react.

Thanks! ❤️

@ahmadalfy
Copy link

@Rolandisimo better than using alpha you can use 5.0.0-RC1

@Rolandisimo
Copy link

Rolandisimo commented Feb 18, 2019

Upgraded to 5.0.0-rc.1.
⚠️Works without addons.

@ahmadalfy Fails with any 4.x.x storybook/addon I've tried.
Reference issue: #5645

@SebPez
Copy link

SebPez commented Feb 25, 2019

@viczhuravlev did you manage to fix it?

@SebPez
Copy link

SebPez commented Feb 25, 2019

I was able to use Storybook 4 and Emotion 10 ONLY when I installed with yarn instead of npm even with different node versions starting a 8.x.x.

     node v11.10.0
    "react": "^16.7.0",
    "react-dom": "^16.7.0"
    "gatsby": "^2.0.115",

    "@babel/core": "7.2.2",
    "babel-loader": "8.0.5",

    "@storybook/addon-actions": "^4.1.11",
    "@storybook/addon-info": "^4.1.11",
    "@storybook/addon-knobs": "^4.1.11",
    "@storybook/react": "4.1.11",

    "@emotion/core": "^10.0.7",
    "@emotion/styled": "^10.0.7",
    "emotion-normalize": "^10.0.0",

@Ziv-Barber
Copy link

To fix this remove all the '@emotion' packages from package.json, remove node_modules and yarn.lock (or package json lock) and yarn install.

masaki-koide added a commit to masaki-koide/my-portfolio that referenced this issue Mar 4, 2019
@artembatura
Copy link

artembatura commented Mar 5, 2019

After all, I downgraded emotion to 0.x.x and it's working fine now.
@emotion/core 0.13.1
@emotion/styled 0.10.6

@ysgk Thanks, it's works with @storybook/react 4.0.9

@benjazehr
Copy link

Has anyone found out what caused the problem in the first place? I am running on the latest versions and still encounter this error

@shilman
Copy link
Member

shilman commented Apr 3, 2019

@angelozehr the original problem was caused by a dependency on react 16.3+ that was introduced in storybook 4.0 due to emotion. Users trying to run older react projects in 4.0 ran into this error. However, in SB4.1 we split the "manager" (UI) and "preview" (user components) into two separate processes so that it was possible to use SB4.1 with older versions of React. Now in 5.0 it appears that the same error message has come back, possibly for a different underlying problem. To make things more difficult/confusing yarn appears to have some weird interactions with Storybook, so in some cases clearing your node_modules and yarn.lock fix some dependency-related problems. 😢

@shilman
Copy link
Member

shilman commented Apr 10, 2019

@angelozehr It is a regression. See #6474

@lppedd
Copy link

lppedd commented Oct 1, 2019

Still happening on 5.2.1. A bit frustrating.
Edit: caused by another dependency importing React 15. Madness.

@shilman
Copy link
Member

shilman commented Oct 1, 2019

@lppedd Are you saying React15 support is broken in 5.2.1?

@lppedd
Copy link

lppedd commented Oct 1, 2019

@shilman apparently yes.

@shilman
Copy link
Member

shilman commented Oct 1, 2019

confirmed 😭

@shilman shilman reopened this Oct 1, 2019
@shilman
Copy link
Member

shilman commented Oct 1, 2019

@ndelangen this is broken in cra-react15 and also on the now deployment, but since storyshots are enabled it apparently doesn't break the build. any ideas?

@shilman
Copy link
Member

shilman commented Oct 14, 2019

Closing this as a dupe to #8284

@shilman shilman closed this as completed Oct 14, 2019
@abudi1416
Copy link

having the same issue when using Storybook along with Angular 11 project

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

No branches or pull requests