Skip to content

Commit c16774c

Browse files
authored
docs: fix correct style prop usage and prop passing in ItemEditModal composition example (#350)
* docs: fix correct style prop usage and prop passing in ItemEditModal composition example * docs: Fixed example code highlighting
1 parent e89f5c3 commit c16774c

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

fundamentals/code-quality/code/examples/item-edit-modal.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function ItemEditModal({ open, items, recommendedItems, onConfirm, onClose }) {
111111
function ItemEditBody({ children, keyword, onKeywordChange, onClose }) {
112112
return (
113113
<>
114-
<div style="display: flex; justify-content: space-between;">
114+
<div style={{ display: "flex", justifyContent: "space-between" }}>
115115
<Input
116116
value={keyword}
117117
onChange={(e) => onKeywordChange(e.target.value)}
@@ -135,34 +135,27 @@ Context API를 활용하면, 데이터의 흐름을 간소화하고 계층 구
135135

136136
조합 패턴을 사용해도, 컴포넌트가 복잡하고 깊다면, ContextAPI를 사용함으로써 불필요한 Props Drilling을 제거할 수 있어요.
137137

138-
```tsx 1,7,14
138+
```tsx 1,11,18
139139
function ItemEditModal({ open, onConfirm, onClose }) {
140140
const [keyword, setKeyword] = useState("");
141141

142142
return (
143143
<Modal open={open} onClose={onClose}>
144-
<ItemEditBody onClose={onClose}>
144+
<ItemEditBody
145+
keyword={keyword}
146+
onKeywordChange={setKeyword}
147+
onClose={onClose}
148+
>
145149
<ItemEditList keyword={keyword} onConfirm={onConfirm} />
146150
</ItemEditBody>
147151
</Modal>
148152
);
149153
}
150154

151-
function ItemEditList({ children, onClose }) {
155+
function ItemEditList({ keyword, onConfirm }) {
152156
const { items, recommendedItems } = useItemEditModalContext();
153157

154-
return (
155-
<>
156-
<div style="display: flex; justify-content: space-between;">
157-
<Input
158-
value={keyword}
159-
onChange={(e) => onKeywordChange(e.target.value)}
160-
/>
161-
<Button onClick={onClose}>닫기</Button>
162-
</div>
163-
{children}
164-
</>
165-
);
158+
return <>{/* items, recommendedItems 렌더링 로직 */}</>;
166159
}
167160
```
168161

fundamentals/code-quality/ja/code/examples/item-edit-modal.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ function ItemEditModal({ open, items, recommendedItems, onConfirm, onClose }) {
8989

9090
return (
9191
<Modal open={open} onClose={onClose}>
92-
<ItemEditBody onClose={onClose}>
92+
<ItemEditBody
93+
keyword={keyword}
94+
onKeywordChange={setKeyword}
95+
onClose={onClose}
96+
>
9397
<ItemEditList
9498
keyword={keyword}
9599
items={items}
@@ -101,10 +105,10 @@ function ItemEditModal({ open, items, recommendedItems, onConfirm, onClose }) {
101105
);
102106
}
103107

104-
function ItemEditBody({ children, onClose }) {
108+
function ItemEditBody({ children, keyword, onKeywordChange, onClose }) {
105109
return (
106110
<>
107-
<div style="display: flex; justify-content: space-between;">
111+
<div style={{ display: "flex", justifyContent: "space-between" }}>
108112
<Input
109113
value={keyword}
110114
onChange={(e) => onKeywordChange(e.target.value)}
@@ -127,34 +131,27 @@ function ItemEditBody({ children, onClose }) {
127131
Context APIを活用することで、データの流れを簡素化し、階層構造全体に簡単に共有することができます。
128132
コンポジションパターンを使用しても、コンポーネントが複雑で深い場合には、ContextAPIを使用することで不必要なProps Drillingを取り除くことができます。
129133

130-
```tsx 1,7,14
134+
```tsx 1,11,18
131135
function ItemEditModal({ open, onConfirm, onClose }) {
132136
const [keyword, setKeyword] = useState("");
133137

134138
return (
135139
<Modal open={open} onClose={onClose}>
136-
<ItemEditBody onClose={onClose}>
140+
<ItemEditBody
141+
keyword={keyword}
142+
onKeywordChange={setKeyword}
143+
onClose={onClose}
144+
>
137145
<ItemEditList keyword={keyword} onConfirm={onConfirm} />
138146
</ItemEditBody>
139147
</Modal>
140148
);
141149
}
142150

143-
function ItemEditList({ children, onClose }) {
151+
function ItemEditList({ keyword, onConfirm }) {
144152
const { items, recommendedItems } = useItemEditModalContext();
145153

146-
return (
147-
<>
148-
<div style="display: flex; justify-content: space-between;">
149-
<Input
150-
value={keyword}
151-
onChange={(e) => onKeywordChange(e.target.value)}
152-
/>
153-
<Button onClick={onClose}>閉じる</Button>
154-
</div>
155-
{children}
156-
</>
157-
);
154+
return <>{/* items, recommendedItems レンダリングロジック */}</>;
158155
}
159156
```
160157

0 commit comments

Comments
 (0)