Random themes
This commit is contained in:
@@ -39,8 +39,13 @@ function App() {
|
||||
const [theme, setTheme] = useAtom(appTheme);
|
||||
useEffect(() => {
|
||||
if (data && themeName) {
|
||||
const temp = data.find((t: any) => t.name === themeName);
|
||||
setTheme(temp);
|
||||
if (themeName !== 'random') {
|
||||
const temp = data.find((t: any) => t.name === themeName);
|
||||
setTheme(temp);
|
||||
} else {
|
||||
const index = Math.floor(Math.random() * data.length);
|
||||
setTheme(data[index]);
|
||||
}
|
||||
}
|
||||
}, [isFetched, themeName]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user