-
Notifications
You must be signed in to change notification settings - Fork 249
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
MF-788: Add swr to allergies widget #383
Conversation
1c6145f
to
f1b8507
Compare
Is this in progress (should be draft) or are you waiting on a review (request some reviewers)? |
Ready for review @brandones |
export const patientAllergiesFormWorkspace = 'patient-allergy-form-workspace'; | ||
export const allergiesToShowCount = 5; |
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.
Matter of taste, but I'd just put this in the file it goes with. It's pretty specific to that component.
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 rules. The code is shorter, has more robust state handling, and does the awesome SWR stuff. Thanks @denniskigen .
Requirements
Summary
This PR sets up the allergies widget to work with SWR. It introduces a reusable
useAllergies
hook that encapsulates fetching of allergies data from the backend using the SWR paradigm.Additionally, it introduces a call to the SWR mutate function which automatically revalidates the allergies widget data immediately after a new allergy is successfully recorded using the allergy form.
Videos
saving-allergy.mp4
revalidate-on-focus.mp4
showing-potentially-stale-data-while-revalidating.mp4
overview-component-pagination.mp4
Related Issue
https://issues.openmrs.org/browse/MF-788