Skip to content

Commit 4bd1452

Browse files
authored
fix: 요청 URL 파라미터 변경
- 로컬 커밋이 미동작해서 직접 수정
1 parent d6e56dc commit 4bd1452

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

frontend/src/components/UnsplashUploader.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { Icon } from '@iconify/react';
2+
import { useEffect, useMemo, useRef, useState } from 'react';
13
import { useRecoilState, useRecoilValue } from 'recoil';
24
import { isImageBright, previewImage, ratioAtom } from '../atom';
3-
import { Icon } from '@iconify/react';
4-
import { useEffect, useRef, useState } from 'react';
55

6-
const FIXED_HEIGHT = 280;
6+
const HEIGHT = 280;
77

88
const UnsplashUploader = () => {
99
let timer: NodeJS.Timer | null = null;
@@ -12,10 +12,11 @@ const UnsplashUploader = () => {
1212
const previewRatio = useRecoilValue(ratioAtom);
1313
const [isLoading, setIsLoading] = useState<boolean>(false);
1414
const mounted = useRef(false);
15-
15+
const width = useMemo(() => Math.round(HEIGHT * previewRatio), [previewRatio]);
16+
1617
const getRandomImage = async () => {
1718
if (!timer) {
18-
const response = await fetch(`https://picsum.photos/${FIXED_HEIGHT * previewRatio}/${FIXED_HEIGHT}?random=${Date.now()}`);
19+
const response = await fetch(`https://picsum.photos/${width}/${HEIGHT}?random=${Date.now()}`);
1920
setIsLoading(true);
2021
timer = setTimeout(function () {
2122
timer = null;
@@ -29,7 +30,7 @@ const UnsplashUploader = () => {
2930
};
3031
useEffect(() => {
3132
if (imageSrc === '') {
32-
fetch(`https://picsum.photos/${FIXED_HEIGHT * previewRatio}/${FIXED_HEIGHT}?random=${Date.now()}`).then((response) => {
33+
fetch(`https://picsum.photos/${width}/${HEIGHT}?random=${Date.now()}`).then((response) => {
3334
setImageSrc(response.url);
3435
});
3536
}
@@ -45,7 +46,7 @@ const UnsplashUploader = () => {
4546
}
4647
>
4748
<Icon className={'w-6 h-6 ' + `${isLoading && `animate-spinner`}`} icon="tabler:refresh" vFlip={true} />
48-
<div className="text-sm">Unsplash 랜덤 이미지 삽입</div>
49+
<div className="text-sm">PICSUM 랜덤 이미지 삽입</div>
4950
</div>
5051
</button>
5152
<label className={`${isBright ? 'text-darken' : 'text-muted'} flex justify-start items-center mt-3`}>

0 commit comments

Comments
 (0)