-
Notifications
You must be signed in to change notification settings - Fork 8
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
usePromise, useCallablePromise → react-query #164
Conversation
{rewriteCallState.state === 'error' && <span className="bg-red-50">{String(rewriteCallState.error)}</span>} | ||
{rewriteCallState.state === 'loading' && <span>Processing...</span>} | ||
{rewriteCallState.state === 'ok' && ( | ||
{error ? <span className="bg-red-50">{String(error)}</span> : null} |
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 write !!error && <span className="bg-red-50">{String(error)}</span>
here?
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.
Updated.
Codecov Report
@@ Coverage Diff @@
## main #164 +/- ##
==========================================
+ Coverage 36.70% 38.19% +1.48%
==========================================
Files 52 50 -2
Lines 2490 2393 -97
Branches 114 112 -2
==========================================
Hits 914 914
+ Misses 1553 1458 -95
+ Partials 23 21 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Rather than use our own bespoke Promise hooks, we should probably just use react-query, which is wildly popular and supports this use case just fine:
https://stackoverflow.com/questions/62340697/react-query-how-to-usequery-when-button-is-clicked
There's a slight behavior change here: previously if you fetched a rewrite and then selected some new text, we'd show the new text and the old rewrite. Now we clear the rewrite. If we want to go back to the old behavior, we could change to
queryKey: []
orqueryKey: [!!selection]
.