-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert App/ directory to use TypeScript #3125
Conversation
src/components/App/App.tsx
Outdated
@@ -1,3 +1,4 @@ | |||
// @ts-nocheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just apply ts-ignore to specific lines instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
src/components/App/App.tsx
Outdated
|
||
interface AppProps { | ||
location: { [key: string]: string } | ||
strings: { [key: string]: string } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use one shared type for strings so if we figure out how to type it better later we only have one spot to update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use GlobalStrings
in types/common
directory, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah if that's an alias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... I think will be facing the second option mentioned here: #3124 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, in the meantime can you point all the string references to one place instead of duplicating { [key: string]: string }?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's probably best to use Record<string, string> which is a builtin type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated the PR with the builtin type as you suggested. I can go ahead and update other instances of { [key: string]: string }
in a separate PR if you approve.
thanks and sorry for late reply :)
src/components/App/App.tsx
Outdated
@@ -137,7 +161,7 @@ const App = (props) => { | |||
return () => { | |||
window.removeEventListener('scroll', handleScroll); | |||
}; | |||
}); | |||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this change the behavior to only happen once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it the expected behavior? clicking on the "back to top" button takes the user to the top of the screen and then the button disappears. user won't be able to click it multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they scroll back down though we want to reenable it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that is what's happening right now. the button appears every time user scrolls 1000px from top and can be clicked to take the user to the top of the screen. to be honest I think it's best practice to have []
in the useEffect hook and if anything it should have a dependency on the scroll.
Please review.
As part of refactoring, this PR converts
src/components/App/
directory to use TypeScript. There were some spots that I wasn't sure how to handle the types so I had to ignore them (@ts-nocheck) for now but feel free to pull down the changes and update the PR.Since the styled-component is a bit old, I wasn't able to convert the
src/components/App/GlobalStyles.jsx
to TypeScript. Can be done once we upgrade to a newer version.