-
Notifications
You must be signed in to change notification settings - Fork 167
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
feat(ui): freight history in stage details #2730
Conversation
Marvin9
commented
Oct 11, 2024
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const queryClient = useQueryClient(); | ||
const navigate = useNavigate(); | ||
|
||
const { freightHistoryPerWarehouse, freightMap } = useMemo(() => { |
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.
@rpelczar I have moved this to useMemo
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2730 +/- ##
==========================================
- Coverage 49.16% 49.16% -0.01%
==========================================
Files 270 270
Lines 19356 19363 +7
==========================================
+ Hits 9516 9519 +3
- Misses 9218 9221 +3
- Partials 622 623 +1 ☔ View full report in Codecov by Sentry. |
} | ||
} | ||
|
||
const freightData = queryClient.getQueryData( |
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.
Why not regular fetch? I think you assumed there are data. Maybe it will work always in our case, but not sure if it is a good practice. You can set a stale property for data in query configuration, so it won't generate a new request. Also, you are sure that if the data are not available, it will be fetched. Let me know what you think.
You are right, this will work in our case. I didn't want to make the query for the data we already have and I wanted to avoid adding context provider or prop drilling to have that data. The closest I can do is ensureQueryData but since its async I have to wrap in effect. I will look whether to make query with invalidation or use ensureQueryData and add state
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
Test drove and this worked quite nicely. 🔥 LGTM as long as @rpelczar feels all his feedback was adequately addressed. |
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.
LGTM