Skip to content

Conversation

@yonghyeun
Copy link
Contributor

결과물

image
image

이전에 실험했던 기능에서 가은님이 피그마에 작성해줬던 형태로 다시 생성해봤습니다. 거지같은 css 는 덤

코드 설명

import StreamingScreen from '@/entities/photo/ui/StreamingScreen';
import CapturedScreen from '@/entities/photo/ui/CapturedScreen';
import PhotoNavBar from '@/entities/photo/ui/PhotoNavBar';
import Button from '@/shared/ui/Button';

import { usePhotoLogic } from '../hooks/domain';

const PhotoApp = () => {
  const {
    photoUrl,
    isCaptured,
    streamingRef,
    photoRef,
    handleCapture,
    handleReCapture,
  } = usePhotoLogic();
  return (
    <div style={wrapperStyle}>
      <PhotoNavBar photoUrl={photoUrl} isCaptured={isCaptured} />
      <div>
        <StreamingScreen ref={streamingRef} isCaptured={isCaptured} />
        <CapturedScreen ref={photoRef} isCaptured={isCaptured} />
      </div>
      <div style={PhotoButtonWrapper}>
        {isCaptured ? (
          <Button onClick={handleReCapture}>다시 촬영</Button>
        ) : (
          <Button onClick={handleCapture}>사진 찍기!</Button>
        )}
      </div>
    </div>
  );
};

export default PhotoApp;

FSD 구조를 생각해서 컴포넌트를 만들 때 PhotoApp 이란 하나의 컴포넌트에서 커스텀훅으로 도메인 로직을 불러오고 entities 에 존재하는 컴포넌트들에게 props 형태로 필요한 로직을 주입하는 형태로 컴포넌트를 생성해봤습니다.

이야기 나눠보고 싶은 것들

조건부 렌더링

조건부 렌더링에 대해서 안좋은 편견을 가지고 있었는데 너무 남발하지만 않으면 나쁘지 않은 거 같기도 합니다.

isCaptured 상태 값에 따라서 버튼을 다르게 렌더링 하는데 저 부분을 원래 조건부 렌더링을 하는 하나의 컴포넌트로 사용할까 ? 도 고민했었습니다.

그런데 그렇게 하다보니 가독성은 좋아지는데 PhotoApp 컴포넌트 자체의 반환값이 코드만 보고 이해하기는 좀 어렵더라고요

yonghyeun and others added 15 commits August 5, 2024 17:05
- vercel 배포하기 위한 nextjs 프레임워크 설치
- google-maps 를 쉽게 사용하기 위해 react-google-maps 라이브러리 설치
- google maps ID 저장
- FSD 폴더 구조 생성
- 실시간 트랙킹 위해 5000ms 간격으로 setInterval 로 현재 위치 상태 변경
- 5초에 한 번씩 AdvancedMarker 가 추가됨
    사진과 관련된 비즈니스 로직을 모두 usePhotoLogic 이란 훅으로 추상화하여
    사용하도록 함

    streaming 되는 엘리먼트와 캡쳐된 엘리먼트를 isCapture 상태에 따라
    display 값을 통해 렌더링 함
    - 조건부 렌더링을 시행하지 못한 이유는 두 엘리먼트가 actual dom 에
      존재해야만 handleCapture 메소드가 작동 할 수 있기 때문
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants