Closed Dex491 closed 1 year ago
Use this example to implement the search parameters and reading of query parameters from the url: https://reactgo.com/react-router-query-params/
I think I am unclear fully about the flow:
1) the search bar is in /search/query=...
page, which will be the <SearchResults>
component; here is where you then unpackage the query and submit the useEffect to fetch data and then apply the filters on the retrieved data.
Hence, please break down the text above into some headings: each heading is the
Also not clear in which folder I should create the SearchResults
component.
In terms of this comment, we create a folder called 'search' and the SearchResults component will sit inside of there
- this will be done in issue #190, we just updated it to make this more clear
Implementation of filtering search results:
Within Header.js:
SearchResults
component and pass down what the user typed in the search bar through the Link to theSearchResults
componentuseLocation
to pass it down thesearchQuery
/search?query=...
where the ... is what the user searchedWithin SearchResults.js
searchQuery
,setSearchQuery
searchParams
for users/cohorts usinguseSearchParams
fromreact-router-dom
searchParams
to update the url/search?query=...
where the ... is what the user searchedhandleSubmit
we setsearchParams
to thesearchQuery
state valueincludes()
when looping through data to filter through every property.