-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Migrate to functional components - 1 #1800
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.
@Inbal-Tish
Overall the refactor looks good, But I notice a performance degradation in this PR.
I see that the Basic Day component for example now render each time (all days are being rendered when switching between two days!)
I suggest using this hook to investigate the source of wasteful renders.
In general from a quick look, I see that we pass BasicDay the date
prop which seem to be a new object reference each time.
Any reason why shouldn't we pass a day string? (and generate an object internally with date utils)
Also I notice that the Day component accepts a day
prop of XDate type. Also here, I think we can use date string instead and internally create an XDate.
I believe that if we'll avoid passing date objects between components we'll see a huge improvement.
src/calendar/header/index.tsx
Outdated
accessibilityActions={[ | ||
{name: 'increment', label: 'increment'}, | ||
{name: 'decrement', label: 'decrement'} | ||
]} |
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.
Avoid passing static inline object, you can define as a file const
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 keeping the object as global file const? it's static
Done and done. Good catch, great hook! |
…eader updates" This reverts commit 84bf881.
@Inbal-Tish |
Which render do you console? If you're checking Day component then passing |
Im adding console to the day component. |
src/calendar/day/index.tsx
Outdated
const _isToday = _day ? isToday(_day) : undefined; | ||
const {date, marking, dayComponent, markingType} = props; | ||
const _date = date ? new XDate(date) : undefined; | ||
const _isToday = _date ? isToday(_date) : undefined; |
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.
Consider moving the check for undefined inside isToday
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.
Yes. I already do. fixing here
Yes. Fix was pushed |
private components migration to functional component