MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/rhwdr4/when_the_ceo_starts_writing_code/
r/badcode • u/dedpahn • Dec 16 '21
12 comments sorted by
7
I see nothing wrong here.
1 u/dedpahn Dec 17 '21 I hope you aren't proud of that 0 u/mailslot Dec 16 '21 Forgot the return type on the function? 1 u/Lataero Dec 16 '21 You don't need that for functional components 2 u/mailslot Dec 16 '21 My typescript linter disagrees. :( 0 u/Lataero Dec 16 '21 I recommend not adding stupid rules to your eslint, then 0 u/mailslot Dec 16 '21 F/E guy sets the linter rules.
1
I hope you aren't proud of that
0
Forgot the return type on the function?
1 u/Lataero Dec 16 '21 You don't need that for functional components 2 u/mailslot Dec 16 '21 My typescript linter disagrees. :( 0 u/Lataero Dec 16 '21 I recommend not adding stupid rules to your eslint, then 0 u/mailslot Dec 16 '21 F/E guy sets the linter rules.
You don't need that for functional components
2 u/mailslot Dec 16 '21 My typescript linter disagrees. :( 0 u/Lataero Dec 16 '21 I recommend not adding stupid rules to your eslint, then 0 u/mailslot Dec 16 '21 F/E guy sets the linter rules.
2
My typescript linter disagrees. :(
0 u/Lataero Dec 16 '21 I recommend not adding stupid rules to your eslint, then 0 u/mailslot Dec 16 '21 F/E guy sets the linter rules.
I recommend not adding stupid rules to your eslint, then
0 u/mailslot Dec 16 '21 F/E guy sets the linter rules.
F/E guy sets the linter rules.
5
Image Transcription: Code
import * as React from "react"; export function ImageComponent(props: React.HTMLProps<HTMLImageElement>) { return <img { ... { ... (props as React.CSSProperties), src: props,src}} />; }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
What's wrong here? No function return type? But typescript smart enough to guess return type.
5 u/dedpahn Dec 17 '21 Hello, friend! Let me show you a more sensible definition of this component:type Props = React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>; function ImageComponent(props: Props) { return <img {...props} /> }Of course, this is equivalent to just using <img /> directly. Hope that helps! 1 u/dankmolot evil Dec 17 '21 Thanks! Never thought about this way.
Hello, friend! Let me show you a more sensible definition of this component:
type Props = React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>; function ImageComponent(props: Props) { return <img {...props} /> }
Of course, this is equivalent to just using <img /> directly. Hope that helps!
<img />
1 u/dankmolot evil Dec 17 '21 Thanks! Never thought about this way.
Thanks! Never thought about this way.
What's the props? (pun intended) #TeamVue btw
7
u/Bluemooses Dec 16 '21
I see nothing wrong here.
5
u/alexanderhameowlton Dec 16 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/dankmolot evil Dec 17 '21
What's wrong here? No function return type? But typescript smart enough to guess return type.
2
u/Ellogwen Dec 17 '21
What's the props? (pun intended) #TeamVue btw