Coder Social home page Coder Social logo

Comments (9)

1Jesper1 avatar 1Jesper1 commented on May 29, 2024 1

and if you don’t include the shim, you’re saying it doesn’t crash? (note that you should also be using the es6-shim as wel

Sorry, made the wrong assumption, still errors when not including the shim. The problem lies in Storybook. This thread can be closed.

from es5-shim.

ljharb avatar ljharb commented on May 29, 2024

I'm not sure what you mean. PropTypes.shape only works with an object, not with undefined or null, and Object.keys always throws with null or undefined. PropTypes.shape() is incorrect.

from es5-shim.

1Jesper1 avatar 1Jesper1 commented on May 29, 2024

@ljharb React doesn't require it: See jsx-eslint/eslint-plugin-react#1471

from es5-shim.

ljharb avatar ljharb commented on May 29, 2024

@1Jesper1 if they're passing the argument value into Object.keys() then they do require it, since that always throws on null or undefined.

That linked issue is about the linter crashing on it, which is unrelated.

Can you provide the full stack trace, and the code for your shape creation?

from es5-shim.

1Jesper1 avatar 1Jesper1 commented on May 29, 2024

Using:

static propTypes = {
		style: PropTypes.shape(),
	}

crashes on return originalKeys(object);

from es5-shim.

ljharb avatar ljharb commented on May 29, 2024

and if you don’t include the shim, you’re saying it doesn’t crash? (note that you should also be using the es6-shim as well)

from es5-shim.

1Jesper1 avatar 1Jesper1 commented on May 29, 2024

It doesn't crash when I don' include require("airbnb-js-shims"); https://github.com/airbnb/js-shims

from es5-shim.

ljharb avatar ljharb commented on May 29, 2024

That's very bizarre. Can you provide the entire stack trace?

from es5-shim.

1Jesper1 avatar 1Jesper1 commented on May 29, 2024
 TypeError: Cannot convert undefined or null to object
    at keys (<anonymous>)
    at Function.keys (http://localhost:9001/static/iframe.bundle.js:42468:24)
    at Shape.render (http://localhost:9001/static/iframe.bundle.js:18793:39)
    at finishClassComponent (http://localhost:9001/static/iframe.bundle.js:155929:31)
    at updateClassComponent (http://localhost:9001/static/iframe.bundle.js:155884:24)
    at beginWork (http://localhost:9001/static/iframe.bundle.js:156832:16)
    at performUnitOfWork (http://localhost:9001/static/iframe.bundle.js:160500:12)
    at workLoop (http://localhost:9001/static/iframe.bundle.js:160540:24)
    at renderRoot (http://localhost:9001/static/iframe.bundle.js:160623:7)
    at performWorkOnRoot (http://localhost:9001/static/iframe.bundle.js:161530:7)

I think the problem is in Storybook Shape.js class: Object.keys(propTypes).map(function

from es5-shim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.