question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object is not a function

See original GitHub issue

Describe the bug

Opening up Storybook which has addon-docs enabled as an addon will result in an infinitely loading page and the following error in the console:

core.browser.esm.js:10 Uncaught TypeError: Object(...) is not a function
    at Module../node_modules/@emotion/core/dist/core.browser.esm.js (core.browser.esm.js:10)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Module../node_modules/@emotion/styled-base/dist/styled-base.browser.esm.js (styled-base.browser.esm.js:1)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Module../node_modules/@emotion/styled/dist/styled.browser.esm.js (styled.browser.esm.js:1)
    at __webpack_require__ (bootstrap:789)
    at fn (bootstrap:150)
    at Object../node_modules/@storybook/theming/dist/index.js (index.js:39)

Expected behavior Not to throw an error

Screenshots Screenshot with infinite loading and console error. Screenshot 2020-06-12 at 12 08 47

System: Environment Info:

System: OS: macOS 10.15.3 CPU: (12) x64 Intel® Core™ i9-8950HK CPU @ 2.90GHz Binaries: Node: 10.16.3 - /usr/local/bin/node npm: 6.13.0 - /usr/local/bin/npm Browsers: Chrome: 84.0.4147.45 Safari: 13.0.5 npmPackages: @storybook/addon-docs: ^5.3.19 => 5.3.19 @storybook/addon-storysource: ^5.3.19 => 5.3.19 @storybook/preact: ^5.3.19 => 5.3.19 @storybook/preset-scss: ^1.0.2 => 1.0.2

Additional context main.js file

module.exports = {
    stories: ['../**/*.stories.[tj]sx'],
    addons: [
        '@storybook/addon-docs',
        '@storybook/addon-storysource',
        '@storybook/preset-scss'
    ]
};

It works just fine without addon-docs. It doens’t matter the order that I put the addons in, the error will still occur.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vanpanacommented, Jun 12, 2020

Just to check that preact/compat is working, I changed the Button component on your branch to

import { h } from 'preact';
import Preact from 'preact/compat';

/**
 * The button component will render a clickable button
 */
export default class Button extends Preact.Component {
  render() {
    const TagName = this.props.href ? 'a' : 'button';

    return (
      <TagName class="button" href={this.props.href} {...this.props}>
      {this.props.children}
    </TagName>
    )
  }
}

And it is indeed working. That probably means, somehow, my code is faulty.

If I find any clue, I’ll update this issue in case others have this problem.

1reaction
shilmancommented, Jun 12, 2020

@vanpana might be an issue with preact/compat? i’ve added a working example of addon-docs to our sample project here: https://github.com/storybookjs/storybook/pull/11145

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript "Uncaught TypeError: object is not a function ...
Try to have the function body before the function call in your JavaScript file.
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
TypeError: Object(...) is not a function · Issue #14484 - GitHub
What is the current behaviour? I have created react functional component and implement state full logic using useState method but it throws an ......
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
JavaScript: Uncaught TypeError: n is not a function
This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found