-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
37 lines (32 loc) · 1.01 KB
/
App.tsx
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
import * as React from 'react'
import { getMonsFromIndex, getMonsFromMf, getMasterfile } from './utils'
import { AUDIO_STYLES, ICON_STYLES } from './styles'
import { Virtual } from './Virtual'
import type { Props, RawMon } from './types'
export default function App() {
const [mons, setMons] = React.useState<Props[]>([])
const [rawMons, setRawMons] = React.useState<RawMon[]>([])
const [icon, setIcon] = React.useState(ICON_STYLES[0])
const [audio, setAudio] = React.useState(AUDIO_STYLES[0])
const [full, setFull] = React.useState(false)
React.useLayoutEffect(() => {
if (!full) {
getMasterfile().then((newRawMons) => setRawMons(newRawMons))
}
}, [full])
React.useEffect(() => {
;(full
? getMonsFromIndex(icon, audio)
: getMonsFromMf(icon, audio, rawMons)
).then((newMons) => setMons(newMons))
}, [rawMons, icon, audio, full])
return (
<Virtual
mons={mons}
setAudio={setAudio}
setIcon={setIcon}
full={full}
setFull={setFull}
/>
)
}