Audio/Video: fix initial size with useLayoutEffect for React 18

environments/review-renovate-m-t65ngm/deployments/2169
Alex Gleason 2023-01-06 11:46:14 -06:00
rodzic dbb745f38d
commit 8730a276c7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
import classNames from 'clsx';
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import Icon from 'soapbox/components/icon';
@ -397,7 +397,7 @@ const Audio: React.FC<IAudio> = (props) => {
const progress = Math.min((currentTime / getDuration()) * 100, 100);
useEffect(() => {
useLayoutEffect(() => {
if (player.current) {
_setDimensions();
}

Wyświetl plik

@ -1,7 +1,7 @@
import classNames from 'clsx';
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import Blurhash from 'soapbox/components/blurhash';
@ -159,7 +159,7 @@ const Video: React.FC<IVideo> = ({
}
};
useEffect(() => {
useLayoutEffect(() => {
setDimensions();
}, [player.current]);