import React, { useEffect, MouseEvent } from "react"; import { Outlet, useSearchParams } from "react-router-dom"; import Theme from "./theme"; import Citylist from "./citylist"; import getpic from "./pic"; const initSearchParams = { "theme": "", "city": "" } export default function Body() { const [searchParams, setSearchParams] = useSearchParams(initSearchParams) let getpics = getpic(); useEffect(() => { console.log(searchParams.get('theme'), searchParams.get('city')) // setSearchParams(searchParams) }, []) const themeHandleClick = (event: MouseEvent) => { console.log(`theme id= ${event.currentTarget.id}`) setSearchParams({ ...Object.fromEntries(searchParams), theme: event.currentTarget.id, }) } const cityHandleClick = (event: MouseEvent) => { console.log(`city id= ${event.currentTarget.id}`) setSearchParams({ ...Object.fromEntries(searchParams), city: event.currentTarget.id }) } const Idpics = getpics.filter(p => p.themeid == searchParams.get('theme')&& p.cityid == searchParams.get('city') ) return (
{Idpics.map((pic, index:number) => (

{pic.name}

))}
// Body Page ); };