Skip to content

Commit

Permalink
use swr instead of effect
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Jul 15, 2023
1 parent 107b7f8 commit b3511ae
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions web/src/routes/Export.jsx
Expand Up @@ -6,12 +6,11 @@ import axios from 'axios';
import { baseUrl } from '../api/baseUrl';
import { Fragment } from 'preact';
import ActivityIndicator from '../components/ActivityIndicator';
import { useEffect } from 'react';

export default function Export() {
const { data: config } = useSWR('config');
const { data: exports } = useSWR('exports/', (url) => axios({ baseURL: baseUrl, url }).then((res) => res.data));

const [exports, setExports] = useState([]);
const [camera, setCamera] = useState('select');
const [playback, setPlayback] = useState('select');
const [message, setMessage] = useState({ text: '', error: false });
Expand All @@ -27,10 +26,6 @@ export default function Export() {
const [endDate, setEndDate] = useState(localISODate);
const [endTime, setEndTime] = useState('23:59');

useEffect(() => {
axios({ baseURL: baseUrl, url: 'exports/' }).then((res) => setExports(res.data));
}, [])

const onHandleExport = () => {
if (camera == 'select') {
setMessage({ text: 'A camera needs to be selected.', error: true });
Expand Down

0 comments on commit b3511ae

Please sign in to comment.