From c61bc466730480be90b412a6b0321f345230a67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 8 Aug 2022 20:05:44 +0200 Subject: [PATCH] Use `useCallback()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/button/Button.tsx | 8 ++++++-- src/video-grid/VideoTileContainer.jsx | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/button/Button.tsx b/src/button/Button.tsx index bc6359d..c29b5f2 100644 --- a/src/button/Button.tsx +++ b/src/button/Button.tsx @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import React, { forwardRef } from "react"; +import React, { forwardRef, useCallback } from "react"; import { PressEvent } from "@react-types/shared"; import classNames from "classnames"; import { useButton } from "@react-aria/button"; @@ -273,8 +273,12 @@ export function FullscreenButton({ fullscreen, ...rest }: FullscreenButtonProps) { + const getTooltip = useCallback(() => { + return fullscreen ? "Exit full screen" : "Full screen"; + }, [fullscreen]); + return ( - "Full screen"}> + diff --git a/src/video-grid/VideoTileContainer.jsx b/src/video-grid/VideoTileContainer.jsx index 22338e7..55de199 100644 --- a/src/video-grid/VideoTileContainer.jsx +++ b/src/video-grid/VideoTileContainer.jsx @@ -22,6 +22,7 @@ import { useRoomMemberName } from "./useRoomMemberName"; import { VideoTile } from "./VideoTile"; import { VideoTileSettingsModal } from "./VideoTileSettingsModal"; import { useModalTriggerState } from "../Modal"; +import { useCallback } from "react"; export function VideoTileContainer({ item, @@ -65,6 +66,10 @@ export function VideoTileContainer({ videoTileSettingsModalState.open(); }; + const onFullscreenCallback = useCallback(() => { + onFullscreen(item); + }, [onFullscreen, item]); + // Firefox doesn't respect the disablePictureInPicture attribute // https://bugzilla.mozilla.org/show_bug.cgi?id=1611831 @@ -85,7 +90,7 @@ export function VideoTileContainer({ onOptionsPress={onOptionsPress} localVolume={localVolume} isFullscreen={isFullscreen} - onFullscreen={() => onFullscreen(item)} + onFullscreen={onFullscreenCallback} {...rest} /> {videoTileSettingsModalState.isOpen && (