-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathApp.tsx
More file actions
72 lines (65 loc) · 2.19 KB
/
App.tsx
File metadata and controls
72 lines (65 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { useCallback, useEffect, useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import Particles, { initParticlesEngine } from "@tsparticles/react";
import './App.css'
import { loadFull } from 'tsparticles';
import type { Container } from '@tsparticles/engine';
function App() {
const [ particlesInitialized, setParticlesInitialized ] = useState(false);
useEffect(() => {
initParticlesEngine(async (engine) => {
if (particlesInitialized) {
return;
}
await loadFull(engine);
}).then(() => {
setParticlesInitialized(true);
})
}, []);
const particlesLoaded = useCallback(async (container?: Container): Promise<void> => {
if (!container) {
return;
}
console.log("Particles loaded", container.actualOptions);
}, []);
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo"/>
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo"/>
</a>
</div>
<h1>Vite + React</h1>
{particlesInitialized && (
<Particles options={{
background: {
color: "#000"
},
particles: {
number: {
value: 100
},
links: {
enable: true
},
move: {
enable: true,
}
}
}} particlesLoaded={particlesLoaded}/>)}
<div className="card">
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}
export default App