File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 11import { useEffect , useState } from 'react'
22import { Helmet } from 'react-helmet'
3+ import { useSearchParams } from 'react-router-dom'
34import api from '../../api'
45import { ListSamplesResponse } from '../../api/sounds/list-samples'
56import Container from '../../components/container'
@@ -45,10 +46,17 @@ function Search() {
4546 } )
4647 }
4748
49+ const [ searchParams , setSearchParams ] = useSearchParams ( )
50+
4851 useEffect ( ( ) => {
49- if ( query . get ( 'q' ) ) {
50- setSearch ( query . get ( 'q' ) ?? '' )
51- handleSearch ( )
52+ if ( searchParams . has ( 'q' ) ) {
53+ const query = searchParams . get ( 'q' )
54+ if ( query ) {
55+ searchParams . delete ( 'q' )
56+ setSearch ( searchParams . toString ( ) )
57+ setSearchParams ( searchParams )
58+ handleSearch ( )
59+ }
5260 } else {
5361 fetchSamples ( )
5462 }
@@ -121,7 +129,7 @@ function Search() {
121129 </ div >
122130
123131 < div className = "flex justify-between items-center" >
124- < p > 500.350 Results</ p >
132+ < p > { samples ?. total_items } Results</ p >
125133 < DropdownSort />
126134 </ div >
127135 </ section >
You can’t perform that action at this time.
0 commit comments