Skip to Content
자바스크립트 + 리액트 디자인 패턴
book

자바스크립트 + 리액트 디자인 패턴

by 애디 오스마니(Addy Osmani), 윤창식
August 2024
Beginner to intermediate
384 pages
7h 38m
Korean
Hanbit Media, Inc.
Content preview from 자바스크립트 + 리액트 디자인 패턴
328
자바스크립트 + 리액트 디자인 패턴
12.11.3
Grid
컴포넌트
Grid
컴포넌트는 수직 및 수평 방향으로 가상화된 표 형태의 데이터를 렌더링합니다. 수평/
수직의 현재 스크롤 위치에 따라 필요한
Grid
셀만 렌더링합니다.
앞서 예시와 동일한 목록을 그리드 레이아웃으로 표시하고 싶다면, 입력 데이터가 다차원 배
열이라고 가정하고
FixedSizeGrid
컴포넌트를 다음과 같이 사용할 수 있습니다.
import React from "react";
import ReactDOM from "react-dom";
import { FixedSizeGrid as Grid } from "react-window";
const itemsArray = [
[{},{},{},...],
[{},{},{},...],
[{},{},{},...],
[{},{},{},...],
];
const Cell = ({ columnIndex, rowIndex, style }) => (
<div
className={
columnIndex % 2
? rowIndex % 2 === 0
? "GridItemOdd"
: "GridItemEven"
: rowIndex % 2
? "GridItemOdd"
: "GridItemEven"
}
style={style}
>
{itemsArray[rowIndex][columnIndex].name} ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI를 위한 필수 수학

AI를 위한 필수 수학

할라 넬슨
클라우드 엔지니어를 위한 97가지 조언

클라우드 엔지니어를 위한 97가지 조언

Emily Freeman, Nathen Harvey, 정기훈(Jung Ki Hun)

Publisher Resources

ISBN: 9791169212571