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 #6311

Closed
VladimirHumeniuk opened this issue Mar 27, 2019 · 21 comments
Closed

Uncaught TypeError: Object(...) is not a function #6311

VladimirHumeniuk opened this issue Mar 27, 2019 · 21 comments

Comments

@VladimirHumeniuk
Copy link

I have this errors in console, when i run Storybook (tried 5.0.5 and 5.0.3). Does anyone faced with this?

Uncaught TypeError: Object(...) is not a function
    at Function.div (vendors~main.cbfa0565136f7756886e.bundle.js:2795)
    at Object.../../../node_modules/@storybook/components/dist/Badge/Badge.js (vendors~main.cbfa0565136f7756886e.bundle.js:15399)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/components/dist/index.js (vendors~main.cbfa0565136f7756886e.bundle.js:16902)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/dist/components/Panel.js (vendors~main.cbfa0565136f7756886e.bundle.js:10776)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/dist/register.js (vendors~main.cbfa0565136f7756886e.bundle.js:13304)
    at __webpack_require__ (runtime~main.7861100cd90c77ea6569.bundle.js:84)
    at Object.../../../node_modules/@storybook/addon-knobs/register.js (vendors~main.cbfa0565136f7756886e.bundle.js:13372)
@shilman
Copy link
Member

shilman commented Mar 27, 2019

This looks a bit like the React version error: #4796

But it doesn't make sense in 5.0, so I'm not sure what's going on...

@VladimirHumeniuk
Copy link
Author

@shilman exactly, because I already tried on 16.8.0 and 16.3.0

@shilman
Copy link
Member

shilman commented Apr 1, 2019

@VladimirHumeniuk did you figure it out?

@VladimirHumeniuk
Copy link
Author

@shilman no, we just abandoned the idea of using the 5.. versions.

@shilman
Copy link
Member

shilman commented Apr 1, 2019

That's a shame. Can you paste your package.json deps?

@VladimirHumeniuk
Copy link
Author

@shilman

    "@emotion/core": "^0.x.x",
    "@storybook/addon-a11y": "^5.0.5",
    "@storybook/addon-actions": "^5.0.5",
    "@storybook/addon-backgrounds": "^5.0.5",
    "@storybook/addon-knobs": "^5.0.5",
    "@storybook/addon-viewport": "^5.0.5",
    "@storybook/react": "^5.0.5",
    "babel-loader": "^8.0.4",
    "eslint": "^5.9.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.3.0",
    "eslint-plugin-flowtype": "^3.2.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "file-loader": "^2.0.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "reset-css": "^4.0.1",
    "storybook-addon-jsx": "^6.0.0",
    "storybook-readme": "^5.0.0"

@ryanrombough
Copy link

I had this same issue. It was because I was still trying to import action from @storybook/react. It is now imported from @storybook/addon-actions. So I had to update:

import { storiesOf, action } from '@storybook/react';

to

import { storiesOf } from '@storybook/react';
import { actions } from '@storybook/addon-actions';

in all of my .stories.js files

@VladimirHumeniuk
Copy link
Author

VladimirHumeniuk commented Apr 2, 2019

@ryanrombough will try to do this, thanks in advance.

UPD: No, it's not our case. We didn't imported actions at all.

@VladimirHumeniuk
Copy link
Author

Tried everything from the scratch on 5.0.6, same errors::
image

@shilman
Copy link
Member

shilman commented Apr 2, 2019

@VladimirHumeniuk Do you happen to have a reproduction I can look at?

@Lelith
Copy link

Lelith commented Apr 3, 2019

@shilman
i also experience the same issue after trying to upgrade from 4 to 5 but i already used @storybook/addon-actions before.
image

other dependencies:

    "react": "^16.8.6",
    "@babel/core": "^7.4.3",

    "@storybook/addon-actions": "^5.0.6",
    "@storybook/addon-info": "^5.0.6",
    "@storybook/addon-links": "^5.0.6",
    "@storybook/addons": "^5.0.6",
    "@storybook/react": "^5.0.6",
    "@storybook/addon-viewport": "^5.0.6",

also adding my config here:

import React from 'react';
import { configure, addDecorator, addParameters } from '@storybook/react';
import { setDefaults, withInfo } from '@storybook/addon-info';
import { configureViewport } from '@storybook/addon-viewport';
require('./style.css');
import { setIntlConfig, withIntl } from 'storybook-addon-intl';
import { addLocaleData } from 'react-intl';
import locale_en from 'react-intl/locale-data/en';
import locale_de from 'react-intl/locale-data/de';
import locale_da from 'react-intl/locale-data/da';
import locale_nl from 'react-intl/locale-data/nl';

addLocaleData([...locale_en, ...locale_de, ...locale_da]);

import messages_en from "../lib/translations/en_COM";
import messages_de from "../lib/translations/de_DE";
import messages_da from "../lib/translations/da_DK";
import messages_nl from "../lib/translations/nl_NL";

const messages = {
    'de': messages_de,
    'da': messages_da,
    'en': messages_en,
    'nl': messages_nl
};

const getMessages = (locale) => messages[locale];

// Set intl configuration
setIntlConfig({
    locales: ['en', 'de', 'da', 'nl'],
    defaultLocale: 'en',
    getMessages
});

function loadStories() {
  require('../stories/Instructions.js');
  const req = require.context('../stories', true, /\.story.js$/);
  req.keys().forEach(filename => req(filename));
}

addDecorator(withInfo);
addDecorator(withIntl);

addDecorator(story => (
    <div className="demoWrapper">
      {story()}
    </div>
));

addParameters({
  options: {
    sortStoriesByKind: true,
  }
})

configure(loadStories, module);

aaaand before i forget node v 11.10.1

@shilman
Copy link
Member

shilman commented Apr 3, 2019

@Lelith Try removing "addon-info"?

@Lelith
Copy link

Lelith commented Apr 4, 2019

@shilman its a quite big component library with many stories and all of them using this addon :/ so will stop migration for now but will update once i tried out eliminating this addon / other addons.

@ericsoco
Copy link

I also ran into this issue. Turned out it was due to the order of exports in my library -- one component was importing a styled-components theme from another module, and accessing it within a styled.div. However, the theme object was exporting after the component in my index.js. Rather than throw an NPE, I saw Uncaught TypeError: Object(...) is not a function.

@smykes
Copy link

smykes commented Jun 11, 2019

The weird part for me is it runs fine locally, but throws this error when deployed too Netlify.

@wlblanchette
Copy link

wlblanchette commented Jul 31, 2019

I ran into this a similar issue and it was related to importing from "@storybook/theming": "5.0.11"
Screen Shot 2019-07-31 at 10 09 13 AM

@RareSecond
Copy link

@smykes Try to check your repo for circular dependencies. I had the exact same problem as you, where running it locally worked as it should, where building (and deploying it) gave me this error.
After removing the circular dependency, it all worked again!

@gsarpy
Copy link

gsarpy commented Aug 26, 2019

I am having this issue as well. I never upgraded Storybook/Emotion but rather the only thing that changed before this error was I installed a new package that does not have any dependencies. (it's just a package that converts \n to <br /> nl2br()).

image

Not sure where to go. Everything else I changed on this branch was simple HTML/JSX changes nothing that should cause an issue with a dependency. I use create-react-app - is there a recommended way to upgrade storybook/emotion or downgrade it if that's a better direction for now?

I have tried deleting node_modules and running an install again. I tried completely deleting my local copy and cloning my project again but no luck.

@divyeshjethwa
Copy link

If you're facing this problem with angular then in my case:

I solved it by importing moduleMetadata from '@storybook/angular' instead of '@storybook/angular/dist/client/preview/types'

@slawomir-marek
Copy link

@divyeshjethwa thanks! You're my savior!

@joshhogg
Copy link

For future troubleshooters, double check that all the required packages for your components are installed in your storybook package (and the same version) as the dependencies in your main project. My old storybook was behind on a react-jss version that I had upgraded in the main project, so I was getting this error.

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