Clean up react bad pratices [SYNTH-224]#1399
Conversation
743f001 to
0270205
Compare
dd70e0d to
eefd0c1
Compare
b338494 to
6d8d27d
Compare
|
|
||
| const AnalyticsConsent: React.FC<AnalyticsConsentProps> = ({ onConsent, onClose }) => { | ||
| return ( | ||
| const AnalyticsConsent = ({ onConsent, onClose }: AnalyticsConsentProps): JSX.Element => ( |
There was a problem hiding this comment.
There are quite a few changes to switch the typing of functional components, what's the theory behind that?
There was a problem hiding this comment.
I think that React.FC<AnalyticsConsentProps> is too broad and AnalyticsConsentProps -> React.JSX.Element is a much more straight forward and narrower type. If we don't use React.FC the return type becomes much more useful, for example (): React.JSX.Element | null tells someone using their lsp hover that the function may not render, without having to view implementation of the component. As far as I can tell, aside from React.FC previously being bad pratice, there's no strong recommendation either way in the react community.
f4c10a5 to
5f4a41b
Compare
|
|
||
| const AnalyticsConsent: React.FC<AnalyticsConsentProps> = ({ onConsent, onClose }) => { | ||
| return ( | ||
| const AnalyticsConsent = ({ onConsent, onClose }: AnalyticsConsentProps): React.JSX.Element => ( |
There was a problem hiding this comment.
My IDE is also warning that React should be imported instead of used as a global namespace to make resolution more reliable
There was a problem hiding this comment.
And this matters less but stylistically I prefer React.ReactElement over React.JSX.Element (which is basically an alias)
5f4a41b to
cb8df2a
Compare
|
lowkey decided that |
cb8df2a to
376c493
Compare
rutmanz
left a comment
There was a problem hiding this comment.
Otherwise LGTM
For the future though, it's a lot more tedious to re-review a PR if you force push because you can't see what's changed since the last review anymore.
Task
SYNTH-224
Symptom
many bad practices which make code less readable and in some cases less performant
Solution
clean up the bad code
Verification
bun run fmt,bun run lintandbun run buildall passBefore merging, ensure the following criteria are met: