eschutho commented on a change in pull request #17124:
URL: https://github.com/apache/superset/pull/17124#discussion_r730106541
##########
File path: superset-frontend/src/components/TimezoneSelector/index.tsx
##########
@@ -96,28 +100,31 @@ const TimezoneSelector = ({ onTimezoneChange, timezone }:
TimezoneProps) => {
const prevTimezone = useRef(timezone);
const matchTimezoneToOptions = (timezone: string) =>
TIMEZONE_OPTIONS.find(option => option.offsets === getOffsetKey(timezone))
- ?.value || DEFAULT_TIMEZONE;
+ ?.value || DEFAULT_TIMEZONE.value;
- const updateTimezone = (tz: string) => {
- // update the ref to track changes
- prevTimezone.current = tz;
- // the parent component contains the state for the value
- onTimezoneChange(tz);
- };
+ const updateTimezone = useCallback(
+ (tz: string) => {
+ // update the ref to track changes
+ prevTimezone.current = tz;
+ // the parent component contains the state for the value
+ onTimezoneChange(tz);
+ },
+ [onTimezoneChange],
+ );
useEffect(() => {
const updatedTz = matchTimezoneToOptions(timezone || moment.tz.guess());
if (prevTimezone.current !== updatedTz) {
updateTimezone(updatedTz);
}
- }, [timezone]);
+ }, [timezone, updateTimezone]);
return (
<Select
- ariaLabel={t('Timezone')}
+ ariaLabel={t('Timezone Selector')}
Review comment:
thank you for pointing that out.
##########
File path: superset-frontend/src/components/TimezoneSelector/index.tsx
##########
@@ -96,28 +100,31 @@ const TimezoneSelector = ({ onTimezoneChange, timezone }:
TimezoneProps) => {
const prevTimezone = useRef(timezone);
const matchTimezoneToOptions = (timezone: string) =>
TIMEZONE_OPTIONS.find(option => option.offsets === getOffsetKey(timezone))
- ?.value || DEFAULT_TIMEZONE;
+ ?.value || DEFAULT_TIMEZONE.value;
- const updateTimezone = (tz: string) => {
- // update the ref to track changes
- prevTimezone.current = tz;
- // the parent component contains the state for the value
- onTimezoneChange(tz);
- };
+ const updateTimezone = useCallback(
+ (tz: string) => {
+ // update the ref to track changes
+ prevTimezone.current = tz;
+ // the parent component contains the state for the value
+ onTimezoneChange(tz);
+ },
+ [onTimezoneChange],
+ );
useEffect(() => {
const updatedTz = matchTimezoneToOptions(timezone || moment.tz.guess());
if (prevTimezone.current !== updatedTz) {
updateTimezone(updatedTz);
}
- }, [timezone]);
+ }, [timezone, updateTimezone]);
return (
<Select
- ariaLabel={t('Timezone')}
+ ariaLabel={t('Timezone Selector')}
Review comment:
thank you for pointing that out. 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]