Skip to content

Commit 0b6d522

Browse files
committed
Implement demo
0 parents  commit 0b6d522

15 files changed

+11869
-0
lines changed

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# react-list-virtualization-example
2+
3+
Rendering long lists using virtualization with React
4+
5+
## Documentation
6+
7+
[https://www.cluemediator.com/rendering-long-lists-using-virtualization-with-react](https://www.cluemediator.com/rendering-long-lists-using-virtualization-with-react)
8+
9+
## Quick Start
10+
11+
Follow the below steps to run the project.
12+
13+
1. Clone repository
14+
2. Run `npm i` command to install dependencies
15+
3. Execute `npm start` command to run the project
16+
17+
## Output
18+
19+
[![React Example](https://www.cluemediator.com/wp-content/uploads/2023/01/output-rendering-long-lists-using-virtualization-with-react-clue-mediator.gif)](https://www.cluemediator.com/rendering-long-lists-using-virtualization-with-react)
20+
21+
**Follow us on [GitHub](https://github.com/cluemediator) for more update.**
22+
23+
## Connect with us
24+
25+
Website: [Clue Mediator](https://www.cluemediator.com)
26+
Like us on [Facebook](https://www.facebook.com/thecluemediator)
27+
Follow us on [Twitter](https://twitter.com/cluemediator)
28+
Join us on [Telegram](https://t.me/cluemediator)
29+
Subscribe us on [YouTube](https://www.youtube.com/ClueMediator)
30+
Follow us on [Instagram](https://www.instagram.com/clue_mediator)

package-lock.json

+11,630
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "react-list-virtualization-example",
3+
"description": "Rendering long lists using virtualization with React",
4+
"author": {
5+
"name": "Clue Mediator",
6+
"email": "[email protected]",
7+
"url": "https://www.cluemediator.com"
8+
},
9+
"version": "0.1.0",
10+
"private": true,
11+
"dependencies": {
12+
"react": "^18.2.0",
13+
"react-dom": "^18.2.0",
14+
"react-scripts": "5.0.1",
15+
"react-virtualized": "^9.22.3"
16+
},
17+
"scripts": {
18+
"start": "react-scripts start",
19+
"build": "react-scripts build",
20+
"test": "react-scripts test",
21+
"eject": "react-scripts eject"
22+
},
23+
"eslintConfig": {
24+
"extends": [
25+
"react-app",
26+
"react-app/jest"
27+
]
28+
},
29+
"browserslist": {
30+
"production": [
31+
">0.2%",
32+
"not dead",
33+
"not op_mini all"
34+
],
35+
"development": [
36+
"last 1 chrome version",
37+
"last 1 firefox version",
38+
"last 1 safari version"
39+
]
40+
}
41+
}

public/favicon.ico

3.78 KB
Binary file not shown.

public/index.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>React App</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

public/logo192.png

5.22 KB
Loading

public/logo512.png

9.44 KB
Loading

public/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

src/App.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { List } from 'react-virtualized';
3+
import { dataSet } from './utils';
4+
import Item from './Item';
5+
6+
function App() {
7+
return (
8+
<div className="App">
9+
<h4>Rendering long lists using virtualization with React - <a href="https://www.cluemediator.com">Clue Mediator</a></h4>
10+
<List
11+
width={500}
12+
height={300}
13+
rowCount={dataSet.length}
14+
rowHeight={50}
15+
rowRenderer={Item}
16+
className='list-box'
17+
/>
18+
</div>
19+
);
20+
}
21+
22+
export default App;

src/Item.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { dataSet } from './utils';
3+
4+
const Item = ({
5+
key, // Unique key within array of rows
6+
index, // Index of row within collection
7+
isScrolling, // The List is currently being scrolled
8+
isVisible, // This row is visible within the List (eg it is not an overscanned row)
9+
style, // Style object to be applied to row (to position it)
10+
}) => {
11+
return (
12+
<div key={key} style={style} className='item'>
13+
Clue Mediator - {dataSet[index]}
14+
</div>
15+
);
16+
}
17+
18+
export default Item;

src/index.css

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
body {
2+
margin: 20px;
3+
font-family: Arial, Helvetica, sans-serif;
4+
}
5+
6+
.list-box {
7+
border: 1px solid #ddd;
8+
border-radius: 4px;
9+
}
10+
11+
.item {
12+
background-color: aliceblue;
13+
display: flex;
14+
align-items: center;
15+
padding-left: 10px;
16+
}
17+
18+
.item:nth-child(even) {
19+
background-color: #efefef;
20+
}

src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
4+
import './index.css';
5+
import App from './App';
6+
7+
const root = ReactDOM.createRoot(document.getElementById('root'));
8+
root.render(
9+
<React.StrictMode>
10+
<App />
11+
</React.StrictMode>
12+
);

src/utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// List data as an array of strings
2+
export const dataSet = [...Array(100000).keys()].map(x => `Item ${x + 1}`);

0 commit comments

Comments
 (0)