Skip to content
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

Merged
merged 3 commits into from
Jul 21, 2022

Conversation

Inbal-Tish
Copy link
Collaborator

Move setDate and setDisabled back to Provider and removing the Presenter's relevant tests

Comment on lines 73 to 77
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));
Copy link
Collaborator

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

Copy link
Collaborator Author

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);
Copy link
Collaborator

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

Copy link
Collaborator Author

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
@Inbal-Tish Inbal-Tish merged commit b3937d0 into master Jul 21, 2022
@Inbal-Tish Inbal-Tish deleted the infra/CalendarContextProvider_change_presenter branch July 24, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants