import React, { useState } from 'react'; import { TextField, Button, Box } from '@mui/material'; const SearchBar = ({ onSearch }) => { const [query, setQuery] = useState(''); const handleSearchClick = () => { onSearch(query); }; const handleKeyDown = (e) => { if (e.key === 'Enter') { handleSearchClick(); } }; return ( setQuery(e.target.value)} onKeyDown={handleKeyDown} // Add this line to handle Enter key press /> ); }; export default SearchBar;