Skip to content

Commit

Permalink
fix: cleaned up app.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Victor committed Jan 12, 2023
1 parent 4ef84ea commit 0530372
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
import React, { useEffect } from "react";
import useStore from "@store";
import { Box } from "@components/base";
import { Main } from "@components/inc";
import React from "react";
import { MainLayout, Scaffold } from "@components/inc";

function App() {
const setTheme = useStore((state) => state.setTheme);
useEffect(() => {
setTheme();
}, []);
return (
<>
<Main />
<ImageCache />
<MainLayout />
<Scaffold />
</>
);
}

const ImageCache = () => {
const [photos, setPhotos] = useStore((state) => [
state.photos,
state.setPhotos,
]);
useEffect(() => {
const today = new Date().toDateString();
const todayImage = photos.filter(
(photo) => new Date(photo.for).toDateString() === today
)[0];
if (photos.length === 0 || !todayImage) {
setPhotos("mountains", false);
}
}, []);
return (
<Box css={{ display: "none" }}>
{photos?.map((photo, index) => {
return (
<img
key={index}
src={photo.urls.raw + "&w=2048&q=80&auto=format"}
alt="image"
/>
);
})}
</Box>
);
};
export default App;

0 comments on commit 0530372

Please sign in to comment.