Skip to content

Commit 38b55e5

Browse files
committed
feat: fisrt react migration
1 parent 7932840 commit 38b55e5

22 files changed

+807
-341
lines changed

index.advanced.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
<div id="app" class="max-w-screen-xl h-screen max-h-800 mx-auto p-8 flex flex-col">
2828
<!-- Content will be dynamically generated here -->
2929
</div>
30-
<script type="module" src="./src/advanced/main.advanced.js"></script>
30+
<script type="module" src="./src/advanced/index.tsx"></script>
3131
</body>
3232
</html>

package-lock.json

Lines changed: 89 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
"start:advanced": "vite serve --open ./index.advanced.html",
1212
"test": "vitest",
1313
"test:basic": "vitest basic.test.js",
14-
"test:advanced": "vitest advanced.test.js",
14+
"test:advanced": "vitest advanced.test.ts",
1515
"test:ui": "vitest --ui"
1616
},
1717
"devDependencies": {
1818
"@testing-library/jest-dom": "^6.6.3",
1919
"@testing-library/user-event": "^14.6.1",
20+
"@types/react": "^19.1.9",
21+
"@types/react-dom": "^19.1.7",
2022
"@vitest/ui": "^3.2.4",
2123
"eslint": "^9.32.0",
2224
"eslint-config-prettier": "^10.1.8",
@@ -27,5 +29,8 @@
2729
"prettier": "^3.6.2",
2830
"vite": "^7.0.5",
2931
"vitest": "^3.2.4"
32+
},
33+
"dependencies": {
34+
"@testing-library/react": "^16.3.0"
3035
}
3136
}

src/advanced/App.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { useEffect } from 'react'
2+
import { ShoppingCartProvider, useShoppingCart } from './providers/ShoppingCartProvider'
3+
import { setupSaleTimers } from './controllers/saleTimers'
4+
import { Header } from './components/Header'
5+
import { LeftColumn } from './components/LeftColumn'
6+
import { OrderSummary } from './components/OrderSummary'
7+
import { HelpModal } from './components/HelpModal'
8+
9+
function AppContent() {
10+
const { updateProductOptions, updateCart } = useShoppingCart()
11+
12+
// 초기화 로직 - 이 부분이 필요해요!
13+
useEffect(() => {
14+
updateProductOptions()
15+
updateCart()
16+
setupSaleTimers()
17+
}, [updateProductOptions, updateCart])
18+
19+
return (
20+
<div className="max-w-screen-xl h-screen max-h-800 mx-auto p-8 flex flex-col">
21+
<Header />
22+
<div className="grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 flex-1 overflow-hidden">
23+
<LeftColumn />
24+
<OrderSummary />
25+
</div>
26+
<HelpModal />
27+
</div>
28+
)
29+
}
30+
31+
function App() {
32+
return (
33+
<ShoppingCartProvider>
34+
<AppContent />
35+
</ShoppingCartProvider>
36+
)
37+
}
38+
39+
export default App

src/advanced/__tests__/advanced.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('advanced 테스트', () => {
3838

3939
describe.each([
4040
{ type: 'origin', loadFile: (): Promise<any> => import('../../main.original.js') },
41-
{ type: 'react', loadFile: (): Promise<any> => import('../main.advanced.ts') },
41+
{ type: 'react', loadFile: (): Promise<any> => import("../../advanced/") },
4242
])('$type 장바구니 상세 기능 테스트', ({ loadFile }) => {
4343
let sel: HTMLSelectElement
4444
let addBtn: HTMLButtonElement

0 commit comments

Comments
 (0)