Skip to content

Commit 27cf9d9

Browse files
fix: resolved conflicts
1 parent a205b93 commit 27cf9d9

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

src/content/learn/thinking-in-react.md

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,9 @@ Mockup 看起來像這樣:
3737

3838
依據你的專業背景,你可以用不同的方式來思考如何將設計拆解成 component:
3939

40-
<<<<<<< HEAD
41-
* **程式設計**--就像你寫程式時會判斷是否該建立新的函式或物件一樣,也可以用相同的技巧來拆 component。其中一個常見的技巧叫做[單一職責原則](https://en.wikipedia.org/wiki/Single_responsibility_principle),也就是說,理想的情況下,每個 component 應該只做一件事情。如果某個 component 隨著開發越來越複雜,它就應該被分解成更小的 child component。
40+
* **程式設計**--就像你寫程式時會判斷是否該建立新的函式或物件一樣,也可以用相同的技巧來拆 component。其中一個常見的技巧叫做[單一職責原則](https://en.wikipedia.org/wiki/Separation_of_concerns),也就是說,理想的情況下,每個 component 應該只做一件事情。如果某個 component 隨著開發越來越複雜,它就應該被分解成更小的 child component。
4241
* **CSS**--思考會在那些地方使用類別選擇器 (不過 component 通常並不會拆解得像 CSS 那麼細)
4342
* **Design**--思考你會如何安排設計稿的圖層結構
44-
=======
45-
* **Programming**--use the same techniques for deciding if you should create a new function or object. One such technique is the [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns), that is, a component should ideally only be concerned with one thing. If it ends up growing, it should be decomposed into smaller subcomponents.
46-
* **CSS**--consider what you would make class selectors for. (However, components are a bit less granular.)
47-
* **Design**--consider how you would organize the design's layers.
48-
>>>>>>> f8c81a0f4f8e454c850f0c854ad054b32313345c
4943

5044
假如你的 JSON 架構設計非常棒,通常會發現它可以很自然地對應到 UI 的 component 架構。那是因為 UI 與資料模型通常會擁有相同的資訊架構 -- 也就是相同的結構。將 UI 拆成一個個 component,讓每一個 component 都能對應到資料模型中的一部分。
5145

@@ -282,17 +276,17 @@ Props 和 state 雖然不同,但它們會一起運作。parent component 通
282276
```js
283277
function FilterableProductTable({ products }) {
284278
const [filterText, setFilterText] = useState('');
285-
const [inStockOnly, setInStockOnly] = useState(false);
279+
const [inStockOnly, setInStockOnly] = useState(false);
286280
```
287281
288282
接著,將 `filterText``inStockOnly` 這兩個值作為 props,傳遞給 `ProductTable``SearchBar`
289283
290284
```js
291285
<div>
292-
<SearchBar
293-
filterText={filterText}
286+
<SearchBar
287+
filterText={filterText}
294288
inStockOnly={inStockOnly} />
295-
<ProductTable
289+
<ProductTable
296290
products={products}
297291
filterText={filterText}
298292
inStockOnly={inStockOnly} />
@@ -312,10 +306,10 @@ function FilterableProductTable({ products }) {
312306

313307
return (
314308
<div>
315-
<SearchBar
316-
filterText={filterText}
309+
<SearchBar
310+
filterText={filterText}
317311
inStockOnly={inStockOnly} />
318-
<ProductTable
312+
<ProductTable
319313
products={products}
320314
filterText={filterText}
321315
inStockOnly={inStockOnly} />
@@ -393,13 +387,13 @@ function ProductTable({ products, filterText, inStockOnly }) {
393387
function SearchBar({ filterText, inStockOnly }) {
394388
return (
395389
<form>
396-
<input
397-
type="text"
398-
value={filterText}
390+
<input
391+
type="text"
392+
value={filterText}
399393
placeholder="Search..."/>
400394
<label>
401-
<input
402-
type="checkbox"
395+
<input
396+
type="checkbox"
403397
checked={inStockOnly} />
404398
{' '}
405399
Only show products in stock
@@ -455,9 +449,9 @@ You provided a \`value\` prop to a form field without an \`onChange\` handler. T
455449
function SearchBar({ filterText, inStockOnly }) {
456450
return (
457451
<form>
458-
<input
459-
type="text"
460-
value={filterText}
452+
<input
453+
type="text"
454+
value={filterText}
461455
placeholder="Search..."/>
462456
```
463457
@@ -479,8 +473,8 @@ function FilterableProductTable({ products }) {
479473

480474
return (
481475
<div>
482-
<SearchBar
483-
filterText={filterText}
476+
<SearchBar
477+
filterText={filterText}
484478
inStockOnly={inStockOnly}
485479
onFilterTextChange={setFilterText}
486480
onInStockOnlyChange={setInStockOnly} />
@@ -523,13 +517,13 @@ function FilterableProductTable({ products }) {
523517

524518
return (
525519
<div>
526-
<SearchBar
527-
filterText={filterText}
528-
inStockOnly={inStockOnly}
529-
onFilterTextChange={setFilterText}
520+
<SearchBar
521+
filterText={filterText}
522+
inStockOnly={inStockOnly}
523+
onFilterTextChange={setFilterText}
530524
onInStockOnlyChange={setInStockOnly} />
531-
<ProductTable
532-
products={products}
525+
<ProductTable
526+
products={products}
533527
filterText={filterText}
534528
inStockOnly={inStockOnly} />
535529
</div>
@@ -611,14 +605,14 @@ function SearchBar({
611605
}) {
612606
return (
613607
<form>
614-
<input
615-
type="text"
616-
value={filterText} placeholder="Search..."
608+
<input
609+
type="text"
610+
value={filterText} placeholder="Search..."
617611
onChange={(e) => onFilterTextChange(e.target.value)} />
618612
<label>
619-
<input
620-
type="checkbox"
621-
checked={inStockOnly}
613+
<input
614+
type="checkbox"
615+
checked={inStockOnly}
622616
onChange={(e) => onInStockOnlyChange(e.target.checked)} />
623617
{' '}
624618
Only show products in stock

0 commit comments

Comments
 (0)