Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ ๐Ÿ—บ Map ] UI ์™„์„ฑ ํ›„ ํƒ€์ด๋จธ๊ธฐ๋Šฅ๊นŒ์ง€ ์—ฐ๊ฒฐํ•˜๊ธฐ #9

Merged
merged 16 commits into from
Feb 1, 2023

Conversation

Happhee
Copy link
Collaborator

@Happhee Happhee commented Jan 24, 2023

๐Ÿ”ฅ Related Issues

close #8

๐Ÿ€ ์ž‘์—… ๋‚ด์šฉ

  • ์ง€๋„ ์œ„์— ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ
  • ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ๋งŒ๋“ค๊ธฐ
  • ๋ฆฌ์•กํŠธ ํ›…์œผ๋กœ ํƒ€์ด๋จธ ๊ธฐ๋Šฅ๊ตฌํ˜„ํ•˜๊ธฐ

๐ŸŒˆ PR Point

๐Ÿ’ก utils/useCounter.tsx

์ปค์Šคํ…€ ํ›…์œผ๋กœ ์‹œ๋ถ„์ดˆ ๊ณ„์‚ฐ์„ ๊ตฌํ˜„ํ•˜๊ณ  ๋ฒ„ํŠผ ์ด๋ฒคํŠธ๊นŒ์ง€ useCallback์„ ์ด์šฉํ•ด ๋‚˜ํƒ€๋‚ด์—ˆ์Šต๋‹ˆ๋‹ค!

import { useCallback, useRef, useState } from 'react';

const useCouter = (initMinutes: number, ms: number) => {
  const [count, setCount] = useState(initMinutes);
  const intervalRef = useRef<NodeJS.Timeout | null>(null);

  const start = useCallback(() => {
    if (intervalRef.current) return;
    intervalRef.current = setInterval(() => {
      setCount((prev) => prev + 1);
    }, ms);
  }, []);

  const stop = useCallback(() => {
    if (!intervalRef.current) return;
    clearInterval(intervalRef.current);
    intervalRef.current = null;
  }, []);

  return { count, start, stop };
};

export default useCouter;

๐Ÿ’ก recoil/atom

๋ฆฌ์ฝ”์ผ์„ ํ†ตํ•ด ํ”Œ๋กœ๊น… ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜์—ฌ ์–ด๋Š ํ™”๋ฉด์—์„œ๋„ ํ•ด๋‹น ์ƒํƒœ๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค!

export const floggingInfoState = atom<FloggingData>({
  key: 'floggingInfo',
  default: {
    date: '2023.01.12',
    location: '์ธ์ฒœ',
    distance: 0,
    duration: '00:00:00',
    photo: new FormData(),
  },
  effects_UNSTABLE: [persistAtom],
});

โœ… JupgoButton

์ปค์Šคํ…€๋ฒ„ํŠผ์„ ๋งŒ๋“ค์–ด props์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒŒ ๋ณด์ด๊ณ  ์ด๋ฒคํŠธ๋„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ์™„์„ฑํ•˜์—ฌ ์ง€๋„์—์„œ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค!

interface JupgoButtonProps {
  btnType: string;
  handleBtnClick: React.MouseEventHandler;
}

const JupgoButton = (props: JupgoButtonProps) => {
  const { btnType, handleBtnClick } = props;

  return (
    <JupgoBtn onClick={handleBtnClick} btnType={btnType}>
      {btnType === 'floggingPause' ? (
        <IcTemporaryPause />
      ) : btnType === 'floggingStart' ? (
        <IcFloggingStart />
      ) : (
        <IcStop />
      )}
    </JupgoBtn>
  );
};

๐Ÿ‘€ ์Šคํฌ๋ฆฐ์ƒท / GIF / ๋งํฌ

2023-01-24.4.20.37.mov

๐Ÿ“š Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant