Skip to content

Commit

Permalink
[feat] boostcampwm-2022#85 눈 내리기 구현
Browse files Browse the repository at this point in the history
- 전역으로 상태 관리하여 버튼 토클에 따라 눈내리기 설정 및 해제
  • Loading branch information
ktmihs committed Nov 28, 2022
1 parent 78b20b7 commit 2f2de80
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/page/Town/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { useEffect, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import Game from '../../component/Game';
import Loading from '../../component/Loading';
import Sidebar from '../../component/Sidebar';
import SleepyBoard from '../../component/SleepyBoard';
import Snow from '../../component/Snow';
import { snowState } from '../../store/atom/backgroundSetting';
import { devicePermissionState } from '../../store/atom/deviceSetting';

const Town = () => {
const [isLoadingComplete, setIsLoadingComplete] = useState(false);
const [isClose, setIsClose] = useState(false);

// 전역으로 관리할 예정 (이후 props drilling 제거)
const [permission, setPermission] = useState(false);
const [permission, setPermission] = useRecoilState(devicePermissionState);
const isSnowing = useRecoilValue(snowState);

useEffect(() => {
const getDevicePermission = async () => {
Expand All @@ -30,9 +33,9 @@ const Town = () => {

return (
<>
<Sidebar permission={permission} />
<Sidebar />
<Game />
<Snow />
{isSnowing && <Snow />}
<SleepyBoard />

{isLoadingComplete || <Loading isClose={isClose} />}
Expand Down

0 comments on commit 2f2de80

Please sign in to comment.