Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We could completely close this if it seems overpowered for the use case 🙌
Demo video of admin action :
Screen.Recording.2024-02-20.at.12.23.21.PM.mov
Notes :
Notes
For fetching data
GET
request :useSWR
hook and this also acts as akey
useSWR
will make the GET request with fetch and returns response data along with isLoading,isError
etcrevalidateOnMount: false
)eg :
For
POST
:What this
mutate
function fromuseSWRConfig
does is it internally makes theGET
request forurl
/key
and updates its store maintained for thatkey
/url
Also notice in demo video although we made
GET
request to/api/grants/review
api endpoint after posting review, it didn't show loading spinner and automatically removed the item. I think they achieved this by "mutating" the store for thatkey
/url
properly. Lol I really this experienceOverall I love the experience and makes life a bit simple(like not creating
useEffects
,isLoading
etc), but 100% agree it might be a bit overpoweredcloses #22