'key' & PropTypes

To use the ‘key’ keyword in Dash, I have to add key to the component’s PropTypes, however this then causes errors when running tests as ‘key’ is not actually a prop. Is there a way to allow Dash to accept ‘key’ without it being specified as a proptype?

Thanks for reaching out @lewis! Are you trying to create your own React-Dash components? Could you post a simple example?

Yeah, basically I was working on mapping an existing React component library to Dash, but the React library relies heavily on the presence of the ‘key’ propType. Now adding ‘key’ to MyComponent.propTypes worked fine within Dash, but would cause my pure React tests to fail.

I got around the issue by adding a proxy PropType, i, along with a higher-order component, so key wasn’t specified when creating the component in Dash or a parent, but the component that was rendered does have it.

You can see the code at https://github.com/flightdataservices/dash-grid-layout to get more of an idea of what I mean

1 Like