-
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
CalendarContextProvider - use with pure functions #1932
CalendarContextProvider - use with pure functions #1932
Conversation
const [prevDate, setPrevDate] = useState(date); | ||
const [currentDate, setCurrentDate] = useState(date); | ||
const [updateSource, setUpdateSource] = useState(UpdateSources.CALENDAR_INIT); | ||
const [isDisabled, setIsDisabled] = useState(false); | ||
const [buttonIcon, setButtonIcon] = useState(getButtonIcon(date, showTodayButton)); |
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.
Move useState's before useMemo's
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.
Done
setUpdateSource(updateSource); | ||
setButtonIcon(buttonIcon); | ||
}; | ||
setPrevDate(currentDate); |
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 wonder of these calls trigger multiple renders
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.
When I log the provider, I see one call after setDate
.
…nfra/CalendarContextProvider_change_presenter
Move
setDate
andsetDisabled
back to Provider and removing the Presenter's relevant tests