Use useCallback()

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2022-08-08 20:05:44 +02:00
parent dd304d3569
commit c61bc46673
No known key found for this signature in database
GPG key ID: 4F68B9EC0536B5CC
2 changed files with 12 additions and 3 deletions

View file

@ -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 (
<TooltipTrigger tooltip={() => "Full screen"}>
<TooltipTrigger tooltip={getTooltip}>
<Button variant="icon" {...rest}>
{fullscreen ? <FullscreenExit /> : <Fullscreen />}
</Button>

View file

@ -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 && (