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.

Default props of React components don't end up in Python class.

See original GitHub issue

Related to #174

Hi @shammamah,

When writing tests for the OncoPrint component, I’ve noticed that the ‘simple app’ launched by Selenium didn’t have the same defaults as those specified in OncoPrint (src/lib/components/OncoPrint.react.js) and as seen in the demo app (tests/dashbio_demos/app_onco_print.py). Specifically, I’m referring to prop showoverview, for which the default value is True (which seems to correspond to using Layout(xaxis=dict(rangeslider={'autorange': True})) in a Plotly plot).

Here’s a screenshot of the ‘simple app’, as used in CI tests: still_no_overview as opposed to the demo app: overview

As I dug deeper, I noticed that the OncoPrint class of the dash_bio package did not contain this piece of information (actually, parameter showoverview=Component.UNDEFINED and is optional). More generally, components which result from compiling React components into Python don’t seem to contain any information about default props…

In the demo app, showoverview=True is passed explicitly, it’s not inherited in any way from the OncoPrint component… So, it looks like the whole defaultProps part from React components might be lost in translation when compiling into Python.

Maybe it doesn’t make that much sense to have these defaultProps in the first place?..

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
shammamah-zzcommented, Feb 28, 2019

Yep, this is the case for my SequenceViewer component at the very least, which is a React component.

0reactions
mkcorcommented, Mar 22, 2019

Back when I dug the issue, it actually made sense: That ‘default’ value was never actually passed, so it couldn’t end up in an app (simple version) which doesn’t specify it… In this sense, it’s not a bug. What I’ve noticed is that the issue doesn’t arise in other cases only because the ‘default’ values in question happen to coincide with defaults in native plotly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React not doing deep comparing of defaultProps
defaultProps are only used if the top level prop is undefined. Set the defaultProps of the <User> component instead.
Read more >
A complete guide to React default props - LogRocket Blog
Cover three ways to implement default props in React and provide default values for props that are not required by the component.
Read more >
React Props Cheatsheet: 10 Patterns You Should Know
Props are a powerful tool to use in React, but how do you use them effectively to write robust, reliable React components and...
Read more >
How To Customize React Components with Props
Props are arguments that you provide to a JSX element in a React application. They look like standard HTML props, but they aren't...
Read more >
React: Everything about Default Props | by Chidume Nnamdi
As we described, React components take inputs in the props argument. ... This is passed down from the Parent component. ... The problem...
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