Skip to content

Commit

Permalink
Remove the lazy loader component because
Browse files Browse the repository at this point in the history
there is no need for loading WordClips.json
more than on initial load
  • Loading branch information
Irenej Bozovicar committed Jan 1, 2024
1 parent 3b6dcf0 commit c0d91b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
26 changes: 8 additions & 18 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// src/App.js
import React, { useState, useEffect, lazy } from 'react';
import React, { useState } from 'react';
import { Row, Col } from 'react-bootstrap';
import SearchBar from './components/SearchBar';
import VideoPlayer from './components/VideoPlayer';
Expand All @@ -10,42 +10,32 @@ import FindWordLink from './components/FindWordLink';
import ArrowLeft from './components/ArrowLeft';
import ArrowRight from './components/ArrowRight';
import './App.css';

const LazyWordClips = lazy(() => import('./components/LazyWordClips'));

import WordClipsData from '../WordClips.json';

const App = () => {
const [currentVideoId, setCurrentVideoId] = useState(null);
const [currentClipIndex, setCurrentClipIndex] = useState(0);
const [startTime, setStartTime] = useState(0);
const [searchResults, setSearchResults] = useState([]);
const [placeholderText, setPlaceholderText] = useState('Search for video');
const [wordClips, setWordClips] = useState(null);


useEffect(() => {
const fetchData = async () => {
// Import WordClips.json using dynamic import
const result = await import('./components/LazyWordClips');
setWordClips(result.default);
};

fetchData();
}, []);
const [wordClips, setWordClips] = useState(WordClipsData);

const handleSearch = (searchTerm) => {

const matchingClips = findMatchingClips(searchTerm);
setSearchResults(matchingClips);

if (matchingClips.length > 0) {
setCurrentVideoId(matchingClips[currentClipIndex].videoId);
setStartTime(Math.round(matchingClips[currentClipIndex].startTime));
setCurrentClipIndex(0);
setCurrentVideoId(matchingClips[0].videoId);
setStartTime(Math.round(matchingClips[0].startTime));
} else {
setPlaceholderText('404');
setCurrentVideoId(null);
}
};


const findMatchingClips = (searchTerm) => {
const matchingClips = [];

Expand Down
3 changes: 0 additions & 3 deletions src/components/LazyWordClips.jsx

This file was deleted.

0 comments on commit c0d91b4

Please sign in to comment.