usePromise, useCallablePromise → react-query#164
Merged
Conversation
sehyod
reviewed
Jun 19, 2023
| {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} |
Collaborator
There was a problem hiding this comment.
Why not write !!error && <span className="bg-red-50">{String(error)}</span> here?
cguedes
approved these changes
Jun 20, 2023
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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].