Black Lives Matter. Please consider donating to Black Girls Code today.

[Solved] Import error when trying to test my component in

I’m getting this error at the very first line of my script:

Traceback (most recent call last):
  File "", line 1, in <module>
    import grasia_dash_components
  File "/home/akronix/workspace/grasia-dash-components/grasia_dash_components/", line 10, in <module>
  File "/usr/local/lib/python3.5/dist-packages/dash-0.19.0-py3.5.egg/dash/development/", line 42, in load_components
KeyError: 'props'

All the source code is here:
Nota that demo does work correctly and used to work before I added the Accordion component.

OK, I found what the problem was:
I was using a prop in my react component that wasn’t defined in PropTypes. Adding it fixed it.

The error showed up again :frowning: I’m not even sure if I fixed with that last time.

Some background - Dash creates components dynamically through a metadata.json file (e.g. This metadata.json file is generated from react-docgen from each component’s propTypes.

For example, take a look at the Checklist.react.js component:

This KeyError: 'props' usually means that the metadata.json file isn’t what dash expects it to be (dash could certainly fail more gracefully here!). This can happen because:

  • propTypes is missing
  • Perhaps there is a prop in defaultProps that isn’t included in propTypes
  • npm run prepublish wasn’t run so metadata.json wasn’t generated.

I’d start debugging by inspecting the metadata.json file, comparing it against your code, and looking for any irregularities.

I hope that’s helpful!

1 Like

Wow, that was very helpful!
The problem was as stupid as I wrote Accordion.PropTypes instead of Accordion.propTypes. Curiously, react didn’t throw any warnings about this…Now it’s fixed on my repo:

Definitely, a more explanatory error would be much better.

1 Like

This advice was very helpful! Thank you.

(I ran into the same issue, had made a mistake in my React component, but no errors were thrown when building, and just had the Python KeyError: 'props' when trying to use it.)