const list = new Map([
['rating', 'По популярности'],
['price', 'По цене'],
['title', 'По названию'],
]);
const onClickSort = (item) => {
setSelectedSort(list.get(filter[0]));
setOpenPopup(false);
}
onClickSort('rating');
{[...list].map(item => (
<li
key={i}
onClick={() => onClickSort(item[0])}
className={selectedSort === i ? 'activeSort' : ''}
>
{value}
</li>
))}
const Context = createContext();
function ContextProvider({ children }) {
const [active, setActive] = useState(false);
return <Context.Provider value={{ active, setActive }} >{children}</Context.Provder>
}
function App() {
return (
<ContextProvider>
<MyComponent />
</ContextProvider>
)
}
function MyComponent() {
const { active, setActive } = useContext(Context);
...
}