-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
3.0 RC3 changes. #3175
3.0 RC3 changes. #3175
Conversation
Should the ExternalWrapper also account for pattern-matching ids? Or is this something the dev should account for? |
Yes, should be working now 🙂 |
ExternalComponent( | ||
id="ext", | ||
input_id="external", | ||
text="external", | ||
extra_component={ | ||
"type": "Div", | ||
"namespace": "dash_html_components", | ||
"props": { | ||
"id": "extra", | ||
"children": [ | ||
html.Div("extra children", id={"type": "extra", "index": 1}) | ||
], | ||
}, | ||
}, | ||
), | ||
html.Div(html.Div(id={"type": "output", "index": 1}), id="out"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldnt this be rewritten as:
extra_component = html.Div(html.Div('extra_children', id={'index':1, 'type': 'extra'}),id='extra')
Or was this to test the different ways this could be listed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can they get serialized on the backend, there is the two ways tested here with the children as a div.
addComponentToLayout({ | ||
component: { | ||
type: componentType, | ||
namespace: componentNamespace, | ||
props: {} | ||
props: props | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this unpack in a different way than the standard dash components?
For ease of use, would it be easier to just pass a regular dash component {type, namespace, props}
directly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefixed those type
and namespace
with component
in the ExternalWrapper props to be able to use type
in the ...props
since that is a common prop name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, doesnt Dash deal with this by putting those into props
and passing the whole object
to it? Its not normal to break apart the props
in the way that the ExternalWrapper
is accepting it.
eg. Just the way it is above. Its creating the props
object
by the leftover props by default.
def test_hook010_hook_custom_data(hook_cleanup, dash_duo): | ||
@hooks.custom_data("custom") | ||
def custom_data(_): | ||
return "custom-data" | ||
|
||
app = Dash() | ||
app.layout = [html.Button("insert", id="btn"), html.Div(id="output")] | ||
|
||
@app.callback( | ||
Output("output", "children"), | ||
Input("btn", "n_clicks"), | ||
prevent_initial_call=True, | ||
) | ||
def cb(_): | ||
return ctx.custom_data.custom | ||
|
||
dash_duo.start_server(app) | ||
dash_duo.wait_for_element("#btn").click() | ||
dash_duo.wait_for_text_to_equal("#output", "custom-data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
woo hoo! |
run_server
andlong_callback