-
Notifications
You must be signed in to change notification settings - Fork 281
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
Create PriceRangeFilter
component
#208
Conversation
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.
Copy looks good to me! Can't scrutinize code obvs
const location = useLocation(); | ||
|
||
const filterMarkup = (filter: Filter, option: Filter['values'][0]) => { |
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.
Maybe wrap on useCallback, []
to save some memory
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.
Do you mean save some re-rendering time? I looked into it a bit after your suggestions. Seems params
will change always and re-render will happen anyway. Fixing this will end up making the code complicated. I'd leave this is as it is for now and revisit if necessary.
return <PriceRangeFilter min={min} max={max} />; | ||
|
||
default: | ||
const to = getFilterLink( |
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.
Might want to double check it supports /$lang/
urls too
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.
Works!
if (maxPrice !== '') price.max = maxPrice; | ||
|
||
const newParams = filterInputToParams('PRICE_RANGE', {price}, params); | ||
window.location.href = `${location.pathname}?${newParams.toString()}`; |
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.
window.location.href will cause a full render of root
loaders and what not. I'd use fetcher.load('updatedUrl')
instead
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'll tackle this in next PR, we are looking to avoid full page reloads
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.
👍🏼 nice one!! left some comments. Might be interesting to check with Jacob or Matt to see if there's a way to avoid debouncing.
|
Agree, I'm waiting to review of the design by Adam |
Part of #154
This creates a
PriceRangeFilter
Feedback I need
PriceRangeFilter
because of the debouncing, wdyt of this?