Skip to content

Commit 09e08f9

Browse files
committed
feat: 🎸 updated older structure and added infinite scroll
1 parent b08454d commit 09e08f9

File tree

4 files changed

+9
-30
lines changed

4 files changed

+9
-30
lines changed

2024 Prep/machine_coding/react/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#root {
22
max-width: 1280px;
33
margin: 0 auto;
4-
text-align: center;
4+
/* text-align: center; */
55
}
66

77
.logo {

2024 Prep/machine_coding/react/src/App.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
1-
import reactLogo from './assets/react.svg'
2-
import viteLogo from '/vite.svg'
31
import './App.css'
4-
import { useFetch } from './hooks'
5-
import { Loader } from './components'
2+
import { FileExplorer } from './components'
3+
import { fileExplorerData } from './data'
64

75
function App() {
8-
const { data, isLoading, isError } = useFetch(
9-
'https://jsonplaceholder.typicode.com/posts?_limit=10'
10-
)
11-
12-
if (isLoading) {
13-
return <Loader />
14-
}
156
return (
16-
<>
17-
<div>
18-
<a href="https://vitejs.dev" target="_blank">
19-
<img src={viteLogo} className="logo" alt="Vite logo" />
20-
</a>
21-
<a href="https://react.dev" target="_blank">
22-
<img src={reactLogo} className="logo react" alt="React logo" />
23-
</a>
24-
</div>
7+
<div className="container">
258
<h1>Vite + React</h1>
26-
279
<div>
28-
{data.map(({ id, title }) => (
29-
<div key={id}>{title}</div>
30-
))}
10+
<FileExplorer data={fileExplorerData} />
3111
</div>
32-
</>
12+
</div>
3313
)
3414
}
3515

2024 Prep/machine_coding/react/src/components/InfinteScroll.tsx renamed to 2024 Prep/machine_coding/react/src/components/InfiniteScroll.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import React, { useState, useEffect, useRef } from 'react'
1+
import { useState, useEffect, useRef } from 'react'
22
import Loader from './Loader'
33
import axios from 'axios'
44

5-
Loader
65
const URL = 'https://jsonplaceholder.typicode.com/posts'
76

8-
export default function App() {
7+
export default function InfiniteScroll() {
98
const [data, setData] = useState([])
109
const [currentPage, setCurrentPage] = useState(1)
1110
const observerTarget = useRef(null)

2024 Prep/machine_coding/react/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import './index.css'
66
ReactDOM.createRoot(document.getElementById('root')!).render(
77
<React.StrictMode>
88
<App />
9-
</React.StrictMode>,
9+
</React.StrictMode>
1010
)

0 commit comments

Comments
 (0)