-
Notifications
You must be signed in to change notification settings - Fork 16.6k
refactor: Query search into functional component #13102
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
Conversation
492d934 to
c9efdd2
Compare
8aea363 to
89d67fe
Compare
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.
remove?
|
@AAfghahi just ping me when you need another look! |
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.
I see the issue here. You're saying that setDatabaseId and setUserId are called elsewhere and it would trigger the refreshQueries function as well. Yeah, looks like what you have is the best bet. good catch on that.
28033e9 to
554f481
Compare
Codecov Report
@@ Coverage Diff @@
## master #13102 +/- ##
==========================================
- Coverage 77.05% 73.14% -3.92%
==========================================
Files 897 599 -298
Lines 45710 21135 -24575
Branches 5497 5406 -91
==========================================
- Hits 35224 15460 -19764
+ Misses 10362 5549 -4813
- Partials 124 126 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
0d0928e to
786f965
Compare
|
@AAfghahi you can remove the package-lock.json file since you don't have a package.json update. |
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.
prob don't need this async here/no await
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.
you don't need it for the test to pass, but without them the console throws a console warning and tells you to do it.
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.
we usually call name these in TS with the name of the component, i.e., QuerySearchProps
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.
can we be more specific on the type? string or number?
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.
array type?
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.
So, this one is a bit wonky because the queriesArray is actually taking in a json object that it puts in is an object. I went through some iteration where i was parsing through the json object you receive and pushing it into the empty array, but it wasn't rendering the table.
My issue here was that I can create an object prop and then put it in there, but then that would need me to also create aa prop object for the useState (though I could potentially use null, now that I am thinking about it?).
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 looks great. I think you can remove the comment?
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.
you can name this response. It looks like it's returning an object rather than a promise.
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.
I think React.KeyboardEvent will work
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.
React.ChangeEvent
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.
what does this do?
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.
oh! Yeah this is totally because of the debouncer. Apparently when you have a debouncer in hooks the event.target.value gets lost, so you have to tell it to persist the value. Without this formatting you could type something into the search bar, and it would show up on the screen but it wouldn't actually search for it. Kind of wild.
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.
you can also put the debounce where you call onChange below, so
onChange={debounce(onChange, 200)}
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.
I tried this, but ran into the same problem as above.
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.
ok, we can loop back to this another time.
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.
let's try to define something here rather than any
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.
yeah this bothered me too, and I looked through it is, is there a way to set up an object type without having to go through and create all the props for the object? Looking through the typescript documentation it didn't seem that there was.
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.
same thing on any
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.
nit, but you might as well destructure id and database_name in the arg list.
eschutho
left a comment
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.
looking great. I just left some ts feedback!
81ca321 to
c92d37f
Compare
|
eschutho
left a comment
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.
Thanks @AAfghahi. I think we're ready!
|
🏷 ready-to-merge |
SUMMARY
Made Query Search into a functional component from a class component.
Added to package.json because I added userEvent.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Only refreshesQueries when you press enter in the QuerySearch or press the enter key:

TEST PLAN
I need to implement two more tests for checking when refreshQueries works.
ADDITIONAL INFORMATION