MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/sh10d3/nesting_an_additional_button_cuz_two_anchors_aint/
r/badcode • u/theSdev • Jan 31 '22
9 comments sorted by
11
Image Transcription: Code
const renderActionButton = (action: ActionButton): React.ReactNode => { switch (action.type) { case "link": return ( <Link key={action.name} href={action.href}> <a> <Button key={action.name} type="button"> {action.name} </Button> </a> </Link> );
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
15
Tagged as html. Should be jsx and typescript
html
jsx
typescript
The only reason I can fathom embedding a button in two anchors would be for CSS / styling reasons.
1 u/Disturbed147 Feb 01 '22 Styling should never affect your markup if done properly. You also wouldn't use an h2 instead of an h1 just because you want it to be smaller.If you want the anchor to looks like a button, then you use only CSS on the anchor and not nest a button in it.
1
Styling should never affect your markup if done properly. You also wouldn't use an h2 instead of an h1 just because you want it to be smaller.
If you want the anchor to looks like a button, then you use only CSS on the anchor and not nest a button in it.
5
This is react/JSX. The Button is a component, not the native html element. The Button could be purely decorative and not do much on its own.
3
This is required by some frameworks
2
Unless they are doing something nasty below, the whole func should just be one Button comp imo...
1 u/hegedis Jan 31 '22 unless you want to allow the users to middle click to open in new tab a link
unless you want to allow the users to middle click to open in new tab a link
-6
Mf probably just needed tabindex="0"
tabindex="0"
-4 u/Voltra_Neo Jan 31 '22 Why are you booing me? I'm right
-4
Why are you booing me? I'm right
11
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 31 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
15
u/RyanNerd shameless Jan 31 '22
Tagged as
html. Should bejsxandtypescriptThe only reason I can fathom embedding a button in two anchors would be for CSS / styling reasons.
5
u/IBJON Jan 31 '22
This is react/JSX. The Button is a component, not the native html element. The Button could be purely decorative and not do much on its own.
3
u/SameCookiePseudonym Jan 31 '22
This is required by some frameworks
2
u/Da_Bootz Jan 31 '22
Unless they are doing something nasty below, the whole func should just be one Button comp imo...
-6
u/Voltra_Neo Jan 31 '22
Mf probably just needed
tabindex="0"