LinkButton: use React.Fragment instead

This commit is contained in:
Peter Cai 2020-02-19 20:40:51 +08:00
parent 13bc689305
commit 0e3224c52f
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
1 changed files with 2 additions and 7 deletions

View File

@ -12,17 +12,12 @@ class LinkButton extends React.Component
# We cannot just replace the button with a <Redirect/> when we switch
# because it will cause visual breaks where the button disappears for
# a short while before the actual switch happens.
# Use <ins> as a dumb wrapper because it does not actually create
# an element around our tags.
# (the semantics of <ins> is "inserted content", but this seems
# to be the only sane solution here)
# <https://stackoverflow.com/questions/14162035/how-to-wrap-arbitrary-html-with-a-wrapper-without-breaking-markup>
<ins>
<React.Fragment>
<button {...@props} onClick={(e) => @setState { switch: true }}/>
{
@state.switch and
<Redirect {...@props} />
}
</ins>
</React.Fragment>
export default LinkButton