Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component as props #1965

Merged
merged 33 commits into from
Jun 2, 2022
Merged

Component as props #1965

merged 33 commits into from
Jun 2, 2022

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Mar 11, 2022

Add component as prop support.

Contributor Checklist

  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

@T4rk1n T4rk1n force-pushed the component-as-props branch from b3f688d to dce32fd Compare April 25, 2022 18:09
@T4rk1n T4rk1n force-pushed the component-as-props branch from 7ad588b to 63f7312 Compare April 29, 2022 20:48
@T4rk1n T4rk1n force-pushed the component-as-props branch from d79efe1 to 3a26a40 Compare May 2, 2022 19:38
@T4rk1n T4rk1n force-pushed the component-as-props branch from 75bded4 to 642fbea Compare May 2, 2022 20:46
@T4rk1n T4rk1n force-pushed the component-as-props branch from c34cb38 to 854446c Compare May 2, 2022 21:48
@@ -392,6 +402,14 @@ def __repr__(self):
props_string = repr(getattr(self, "children", None))
return f"{self._type}({props_string})"

@classmethod
def _get_base_nodes(cls):
if not cls._base_nodes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a component has lots of props but none of them accept components, will we run this iteration every time one of them is instantiated? If so, can we avoid that? Moving + ["children"] in here would be one way perhaps?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, it's only iterating over _children_props - so the problem only comes if there are lots of nested props and no base props. Still would be best to avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move that to the generator.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Seems like the way you implemented this is compatible with the old generated components, how hard would it be to add a test to explicitly verify that? ie include a component in the tests that doesn't auto-generate but instead uses the old generator output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a legacy test from the old standard component output.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Add a changelog entry and consider my minor perf comment and I think we're ready to go! 💃

@T4rk1n T4rk1n force-pushed the component-as-props branch from 100da72 to 5beab83 Compare June 2, 2022 16:44
@T4rk1n T4rk1n force-pushed the component-as-props branch from 5beab83 to ebc309a Compare June 2, 2022 17:08
@T4rk1n T4rk1n merged commit 467d4ca into dev Jun 2, 2022
@T4rk1n T4rk1n deleted the component-as-props branch June 2, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants