[TIL/React] 2023/07/03
오늘 한 일파일 구조 변경에 따른 recent todo 재구성회고width와 height를 설정하며, 부모 컴포넌트로부터 논리적으로 접근했다. 평소 css는 단순히 view를 꾸며주는 것 그 이상도 이하도 아니라고 생각했는데, 처음부터 논리적으로 접근하지 않으면 코드가
오늘 한 일
import React, { forwardRef } from "react";
import { useSelector } from "react-redux";
import { styled } from "styled-components";
import { ComponentWrapper } from "../common";
const RecentTodoComponentWrapper = styled.div`
height: 1000px;
background-color: #f1e3d9;
`;
const RecentTodoTitle = styled.h1`
font-weight: bolder;
font-size: 70px;
text-align: center;
border-bottom: 9px solid #c07848;
margin-bottom: 100px;
`;
const RecentTodoImage = styled.img`
width: 100%;
height: 100%;
object-fit: cover;
`;
const RecentTodoContent = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
`;
const RecentTodoText = styled.p`
font-size: 24px;
margin-bottom: 16px;
`;
const RecentTodoComponent = forwardRef((props, ref) => {
const { todo } = useSelector((state) => state.todos);
const mostRecentTodo = todo.length > 0 ? todo[todo.length - 1] : null;
return (
<RecentTodoComponentWrapper ref={ref}>
<ComponentWrapper
style={{
padding: "200px",
boxSizing: "border-box",
}}
>
{/* recent todo area */}
<div
style={{
height: "100%",
width: "55%",
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
}}
>
<RecentTodoContent>
<RecentTodoTitle>{mostRecentTodo?.Title}</RecentTodoTitle>
<RecentTodoText>{mostRecentTodo?.Subtitle}</RecentTodoText>
<RecentTodoText>{mostRecentTodo?.Desc}</RecentTodoText>
</RecentTodoContent>
</div>
{/* image area */}
<div
style={{
height: "100%",
width: "45%",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<RecentTodoImage
src="https://kormedi.com/wp-content/uploads/2021/10/211025_02_01-580x410.jpg"
alt="Recent Todo Image"
/>
</div>
</ComponentWrapper>
</RecentTodoComponentWrapper>
);
});
export default RecentTodoComponent;파일 구조 변경에 따른 recent todo 재구성

회고
width와 height를 설정하며, 부모 컴포넌트로부터 논리적으로 접근했다. 평소 css는 단순히 view를 꾸며주는 것 그 이상도 이하도 아니라고 생각했는데, 처음부터 논리적으로 접근하지 않으면 코드가 무너지는 것을 목도하고, css도 상태관리와 다를 바 없다는 생각이 들었다. 추가적으로, 텍스트와 이미지 모두를 감싸는 div가 없어 border-radius를 줄 수 없었다는 아쉬움이 있었다.
인스타그램은 사진 게시판이다. 트위터는 텍스트 게시판, 유튜브는 영상 게시판이고 쿠팡은 상품 게시판이며 당근마켓은 중고거래 게시판이다. 세상 웬만한 서비스들의 프로토타입은 게시판이라는 뜻이다. 즉, 본질은 결국 게시판을 통한 CRUD 구현이다.
나를 둘러싸고 있는 문제들이 복잡하게 느껴질 때 가장 먼저 떠올려야 하는 문장, "Back to Basics". 오늘도 감사합니다.
More to read
프론트엔드와 백엔드 사이
HTTP 상태 코드는 프론트엔드에서 백엔드로 보냈던 요청의 수행 결과를 의미하는 일종의 약속이며, API를 구성하는 핵심 요소 중 하나입니다. 상태 코드와 관련하여, 백엔드는 잘 모르는 프론트엔드의 슬픈 사정이 있습니다.아래는 요청이 실패했음에도, 백엔드에서 상태 코드
JWT토큰 관리 방식 톺아보기
0. 들어가며 🎯 서비스에 접근하려는 사용자가 누구인지 확인하는 과정을 사용자 인증이라고 합니다. 인증된 사용자에게 주어진 권한을 확인하는 작업은 인가라고 부릅니다. 이번 글에서는 인가는 다루지 않습니다. 사용자 인증에는 많은 방식이 있지만, 오늘은 세션 인증 방
A2AA2A / MCP 멀티 에이전트 오케스트레이션
0. 들어가며 ✍️ Google for Developers에, 레스토랑 공급망 시나리오로 엮은 6대 프로토콜(MCP, A2A, UCP, AP2, A2UI, AG-UI)에 대한 가이드가 게시된 이후, MCP와 A2A부터 구현해 보는 것이 좋을 것 같다는 생각이 들었습니