-
-
Notifications
You must be signed in to change notification settings - Fork 144
772 set href as a required prop and as the default value for children #776
Conversation
''' | ||
return document.getElementById("link1").text; | ||
''' | ||
) |
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.
dash_dcc.wait_for_text_to_equal("#link1", "/page-1")
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.
Added in 4537402.
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.
That statement replaces the whole href_as_children = ...
and assert href_as_children == ...
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'm guessing that method acts as a wrapper of sorts to check the text? Interesting. Updated in da999d5.
Co-Authored-By: alexcjohnson <[email protected]>
src/components/Link.react.js
Outdated
{this.props.children} | ||
{isNil(this.props.children) | ||
? this.props.href | ||
: this.props.children} |
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.
While we're golfing - add children
to the destructuring of this.props
above (href
is already there) and this collapses to just {isNil(children) ? href : children}
That's a nicer pattern anyway, as it shows up front what props get used during the render.
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.
Makes sense, destructuring does look cleaner. Updated in 065c462.
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.
Beautiful! 💃
html.Div(id="content") | ||
] | ||
) | ||
@app.callback(Output("content", "children"), [Input("link1", "children")]) |
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.
Does this callback and content
Div do anything in this test?
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.
Can you add another simple test checking that children are indeed children when defined
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.
Added in 5eac66e.
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.
Quick question about the test and suggested addition for completeness.
html.Div(id="content") | ||
] | ||
) | ||
@app.callback(Output("content", "children"), [Input("link1", "children")]) |
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.
Can you add another simple test checking that children are indeed children when defined
This PR addresses #772 and #773. The
href
prop is marked as required, and if nochildren
prop is defined, thehref
is set as thechildren
by default. As @Marc-Andre-Rivet pointed out, this will simplify usage, and makes more sense for thedcc.Link
component as a whole.Any suggestions on how to better structure the conditional are welcome, would it perhaps be better to set the children directly in the return function (maybe as a ternary operator) instead of as a separate named function?
Closes #772
Closes #773