export default function SearchPage() {
const dispatch = useDispatch()
const location = useLocation()
React.useEffect(() => {
const [gender, typeClothes] = location.pathname.split("/")[2].split("-")
dispatch({
type:'FILTERING-DATA',
filters: [{ gender }, { typeClothes }],
})
}, [location])
return (
<div className='search-page'>
<Filters/>
<ProductList/>
</div>
)
}
import { createHashHistory } from 'history'
import { Router } from 'react-router-dom'
const history = createHashHistory()
ReactDOM.render(
<Router history={history}>
// your app
</Router>
)
import React from 'react';
interface MyComponentProps {
children: (items: string[]) => void;
regexp: RegExp;
items: string[];
}
export const MyComponent: React.FC<MyComponentProps> = ({ children, items, regexp }) => {
return children(items.filter(item => regexp.test(item)));
}