diff --git a/app/assets/javascripts/training/components/training_libraries_list.jsx b/app/assets/javascripts/training/components/training_libraries_list.jsx index 2ba54d4094..55bdd921ee 100644 --- a/app/assets/javascripts/training/components/training_libraries_list.jsx +++ b/app/assets/javascripts/training/components/training_libraries_list.jsx @@ -9,16 +9,23 @@ const TrainingLibraries = () => { const slides = useSelector(state => state.training.slides); const [search, setSearch] = useState(''); const [showSearchResults, setShowSearchResults] = useState(false); + const [isLoading, setIsLoading] = useState(true); const dispatch = useDispatch(); useEffect(() => { dispatch(fetchTrainingLibraries()); -}, [dispatch]); + }, [dispatch]); useEffect(() => { setShowSearchResults(showSearchResults); }, [slides]); + useEffect(() => { + if (libraries.length > 0) { + setIsLoading(false); + } + }, [libraries]); + const handleSearch = (e) => { setSearch(e.target.value); }; @@ -28,6 +35,35 @@ const TrainingLibraries = () => { dispatch(searchTrainingLibraries(search)); setShowSearchResults(true); }; + + if (isLoading) { + return ( +