Comments (2)
import { useState, useEffect } from "react";
import min25 from "assets/images/25min.png";
import min20 from "assets/images/20min.png";
import min15 from "assets/images/15min.png";
import min10 from "assets/images/10min.png";
import min5 from "assets/images/5min.png";
/**
* 5/10/15/20/25분 단위로 줄어드는 시간에 맞춰 이미지 변화시키는 함수
* transition을 이용해서 자연스럽게 이미지가 바뀌게끔 하고 싶은데 어떻게 해야될지 모르겠어요.ㅠ
* 아직 라우팅에 서툴러서 이 내용을 브라우저단에서 확인하고 싶은데 어떻게 해야할지 잘 모르겠네여..미생을 구해쥬세여 선배님들 ㅎㅎ ㅠ
*/
export function TimerImage() {
const timeStamp = [min5, min10, min15, min20, min25];
const [timerImage, setTimerImage] = useState(timeStamp[0]);
const [count, setCount] = useState(0);
const increment = () => setCount((prevCount) => prevCount + 1);
useEffect(() => {
console.log(count);
const interval = setInterval(() => {
if (count % 5 === 0) {
setTimerImage(timeStamp[count / 5]);
}
increment();
}, 1000);
return () => clearInterval(interval);
}, [count]);
return (
<div>
<img src={timerImage} alt={"temp"} />
</div>
);
}
제가 생각한 방식은 이것 입니다!
from dailyreceipt-fe-web.
useInterval 방식으로 해결했습니다!
#14
from dailyreceipt-fe-web.
Related Issues (20)
- [issue] 전반적 레이아웃 / CSS 버그 수정
- [issue] 닉네임 수정 기능 연결 HOT 1
- [issue] 각 영수증을 클릭했을 때 해당 날짜의 영수증 출력 페이지로 이동하기 HOT 2
- [issue] 영수증 핀 / 핀 해제 기능 연결 HOT 1
- [issue] 영수증이 일정 길이가 넘어가면 하단부에 검은선 발생 HOT 2
- [issue] 영수증 타이머 누적시간 출력 단위 오류
- [issue] 11월-12월 작업중 확인한 버그/수정사항 목록
- [issue] 타이머 모달완성 HOT 2
- [issue] 마이페이지에서 보이는 명언이 서버에 저장된 명언이 아니라 새로 불러와지는 명언으로 표시됨 HOT 1
- [issue] 회원일 때 타이머가 infinity로 표시됨 HOT 3
- [feature] 영수증 로딩 기능
- [issue] 각 API 인터페이스의 id명 확인
- [feature] UI 개선 HOT 1
- [issue] 날짜 변경 시 투두리스트가 변경되지 않음(리팩토링) HOT 1
- [issue] 영수증 출력버튼 클릭시 에러 발생 HOT 1
- [issue] 테스트 항목 작성 (WIP)
- [issue] 7월 창고정리
- [issue] Thunder Client 도입 및 테스트 자동화 HOT 1
- [feature] 로그인 테스트용 임시 컨트롤러 작성
- [issue] http 요청시 https로 변환되어 요청됨 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dailyreceipt-fe-web.