import React, { useEffect, useRef } from 'react'; import { useSearchUIContext, useSearchUIContextActions } from '../SearchUIContextProvider'; import { searchUIViewsMap } from '../types'; import { FaExclamationTriangle } from 'react-icons/fa'; /** * Component for rendering SearchUI data in a certain view dynamically * based on the current view state, error state, and number * of results. The view is determined by the `SearchUIContainer`'s `view` prop. */ export const SearchUIDataView: React.FC = () => { const { state, query } = useSearchUIContext(); const getDataView = () => { if (state.error) { return (

There was an error with your search.

You may have entered an invalid search value. Otherwise, the API may be temporarily unavailable.

); } else if (!state.results || state.results.length === 0) { return (

No records match your search criteria

); } else { const SearchUIViewComponent = searchUIViewsMap[state.view!]; return ; } }; return
{getDataView()}
; };