You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add support for setting JSX for title on Dialog props #6032
We want to avoid contributors using Dialog and nesting DialogHeader within if they only want the default behaviour. See #6027 (comment) for more discussion.
I was going to propose using react-to-string here which seems to fit the bill, based on the example:
importReact,{Component}from'react';importreactToStringfrom'react-to-string';classAppextendsComponent{render(){return<div>Hello world!</div>}}reactToString(<App/>);// Returns "Hello world!"reactToString(<p>Are you interested in this library? <ahref="signup">Click here!</a></p>);// Returns "Are you interested in this library? Click here!"
But the library does not have a license, so I've opened kevinzwhuang/react-to-string#3 to ask them to define one before I look at pulling this into our codebase.
It looks like that doesn’t actually render the element so the code might not work as described.
To be clear, I'm only looking for a string-like representation of the element for situations where we need something distinct to work with (the original issue was using the title to generate a unique id). I'm not looking to actually render the elements.
// TODO: how can we get a string-like representation of a JSX element?constid=typeofthis.props.title==='string' ? this.props.title : '???'```
You can ignore this entirely. CreateUniqueId will ensure it's a unique id regardless of what you pass it so just leave that as-is (ie. pass the raw JSX.Element to it, that's fine). You can use createUniqueId without giving it anything if you like and it'll take care of it, we only give it something that's slightly human readable for sanity's sake.
Activity
shiftkey commentedon Oct 30, 2018
I was going to propose using
react-to-stringhere which seems to fit the bill, based on the example:But the library does not have a license, so I've opened kevinzwhuang/react-to-string#3 to ask them to define one before I look at pulling this into our codebase.
j-f1 commentedon Oct 30, 2018
It looks like that doesn’t actually render the element so the code might not work as described.
shiftkey commentedon Oct 30, 2018
To be clear, I'm only looking for a string-like representation of the element for situations where we need something distinct to work with (the original issue was using the title to generate a unique id). I'm not looking to actually render the elements.
shiftkey commentedon Oct 30, 2018
This was the snippet I used in #6027 as a starting point:
niik commentedon Mar 8, 2019
Hey @shiftkey, sorry, I've completed missed this.
You can ignore this entirely. CreateUniqueId will ensure it's a unique id regardless of what you pass it so just leave that as-is (ie. pass the raw JSX.Element to it, that's fine). You can use
createUniqueIdwithout giving it anything if you like and it'll take care of it, we only give it something that's slightly human readable for sanity's sake.shiftkey commentedon Mar 8, 2019
@niik cool, that should simplify the other things in here
shiftkey commentedon Mar 8, 2019
The commit to add this support is 6cf4a2a and this should be resolved in #6961.
shiftkey commentedon Mar 15, 2019
Resolved in #6961, and aside from the usages reported in #7043 there are two others:
desktop/app/src/ui/rebase/rebase-conflicts-dialog.tsx
Lines 167 to 171 in b552932
I'll move these out tohelp wantedtasks that can be picked up by others before closing this out.shiftkey commentedon Mar 15, 2019
Closing this out as the remaining work to cleanup this anti-pattern has been written up