-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: Change lib v2 code to TS #43
refactor: Change lib v2 code to TS #43
Conversation
9694943
to
5cbff4a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## yusuf-musleh/sort-filter-v2-libraries #43 +/- ##
========================================================================
Coverage ? 92.65%
========================================================================
Files ? 712
Lines ? 12724
Branches ? 2800
========================================================================
Hits ? 11789
Misses ? 900
Partials ? 35 ☔ View full report in Codecov by Sentry. |
86f9371
to
f0ea105
Compare
@@ -98,7 +98,7 @@ const LibrariesV2Tab = ({ | |||
</div> | |||
|
|||
{ hasV2Libraries | |||
? data.results.map(({ | |||
? data?.results.map(({ |
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.
react-query guarantees that only one of data
, isLoading
, or isError
will be truthy at any given time, so you can either change this to data!.results
or refactor the code like this:
if (isLoading) {
// Display loading state
}
if (isError || data === undefind) {
// Display an error message. The `|| data === undefined` is only needed for TypeScript to understand the flow.
}
// Render the normal component. Here TypeScript now knows that `data` is not undefined
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 see, I've updated it to use the data!
and made sure that the to check for !isLoaded
in the hasV2Libraries
which is used in a bunch of places. (isError
is already checked at the beginning and returns): a72713e
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.
👍 This works as expected, thank you @yusuf-musleh
- I tested this on my tutor dev stack using the instructions from feat: Add lib v2/legacy tabs in studio home openedx/frontend-app-authoring#1050
- I read through the code
-
I checked for accessibility issuesN/A -
Includes documentationN/A - User-facing strings are extracted for translation
f0ea105
to
5d4c369
Compare
@pomegranited Thanks for the review!
@bradenmacdonald I made sure to run the linter and there are no issues with the file changes in this PR. |
49b7142
to
6888565
Compare
a72713e
to
05eda0a
Compare
6888565
to
2469f04
Compare
This PR is temp for review, should be replaced with openedx#1124 once base PR is merged.