-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Develop #609
base: master
Are you sure you want to change the base?
Develop #609
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.
Good job!
src/components/PeoplePage.tsx
Outdated
.finally(() => setIsLoad(false)); | ||
}, []); | ||
|
||
const getVisiblePeople = () => { |
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.
Better move this function outside the component and just call it here with your arguments.
setIsLoad(true); | ||
getPeople() | ||
.then((peopleFromServer) => setPeople(peopleFromServer)) | ||
.catch(() => { |
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.
Try to catch an error
here, maybe it will fix some of your failed tests
src/components/PeoplePage.tsx
Outdated
|
||
export const PeoplePage = () => { | ||
const [people, setPeople] = useState<Person[] | null>(null); | ||
const [isLoad, setIsLoad] = useState<boolean>(false); |
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.
It is better to make isLoad
true
by default. Now there's no need to set it true
in line 23
</p> | ||
)} | ||
{people && <PeopleTable people={getVisiblePeople()} />} | ||
{!isLoad && !error && !people && ( |
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.
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 I've already fixed it with lowder, because I don't see this problem now
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.
Almost there🔥
src/components/PeoplePage.tsx
Outdated
|
||
useEffect(() => { | ||
getPeople() | ||
.then((peopleFromServer) => setPeople(peopleFromServer)) |
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.
.then(setPeople)
src/components/PeoplePage.tsx
Outdated
people={getVisiblePeople( | ||
people, | ||
sex, | ||
query, | ||
centuries, | ||
sort, | ||
order, | ||
)} |
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.
- For better readability store in separate variable
- Just pass the whole
searchParams
object
src/components/PeopleFilters.tsx
Outdated
<SearchLink | ||
className={classnames({ 'is-active': !sex })} | ||
params={{ sex: null }} | ||
> | ||
All | ||
</SearchLink> | ||
|
||
<SearchLink | ||
className={classnames({ 'is-active': sex === 'm' })} | ||
params={{ sex: 'm' }} | ||
> | ||
Male | ||
</SearchLink> | ||
|
||
<SearchLink | ||
className={classnames({ 'is-active': sex === 'f' })} | ||
params={{ sex: 'f' }} | ||
> | ||
Female | ||
</SearchLink> |
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.
Render as list
className="button is-link is-outlined is-fullwidth" | ||
href="#/people" | ||
params={{ centuries: null, query: null, sex: 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.
Find a better way to reset all by just 1 line of code. If you had 20 filters, would you set null to all of them?
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.
all the other options I can think of
will either just increase the amount of code or reset the sorting as well.
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.
🔥
DEMO LINK