This is a React application that mimics the functionality of Google Search. Users can enter a search term, and the application will display the search results that match the term.
To get started with the React Google Search Copy, follow these steps:
-
Clone the repository:
-
Navigate to the project directory:
-
Install the dependencies:
-
Start the development server:
The application will be available at http://localhost:3000
in your browser.
- Enter a search term in the search bar.
- Press the Enter key or click the "Search" button.
- The application will display the search results.
The App
component is the main component of the application. It manages the search functionality and displays the search results.
results
: An array of search results.searchTerm
: The current search term entered by the user.
setValue(str)
: Updates thesearchTerm
state with the provided string.search(e, str)
: Handles the search functionality. It prevents the default form submission, checks if the search bar is empty, and calls theapiSearch
method to fetch the search results from the API.apiSearch()
: Sends a GET request to the API with the currentsearchTerm
and updates theresults
state with the retrieved search results.
The App
component renders a navigation bar with a logo and a search bar. It also displays the number of search results and a list of search result components (Result
) for each item in the results
array.
The Result
component is a child component of App
and represents a single search result.