Добавление открытия / закрытия модалки создания задачи (#78)
* Добавить открытие\закрытие модалки создания задачи #63 написал каркас функции и рендеринга, настроил открытие и закрытие модалки
This commit is contained in:
26
src/app/components/popup-list-item/PopupListItem.tsx
Normal file
26
src/app/components/popup-list-item/PopupListItem.tsx
Normal file
@ -0,0 +1,26 @@
|
||||
import {ListItem, ListItemText} from '@material-ui/core';
|
||||
import React, {memo, useCallback} from 'react';
|
||||
import {useHistory} from 'react-router-dom';
|
||||
|
||||
type PopupListItemProps = {
|
||||
item: string;
|
||||
url: string;
|
||||
setOpen: (isOpen: boolean) => void;
|
||||
};
|
||||
|
||||
const PopupListItem: React.FC<PopupListItemProps> = ({item, url, setOpen}) => {
|
||||
const history = useHistory();
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
setOpen(false);
|
||||
history.push(url);
|
||||
}, [history, setOpen, url]);
|
||||
|
||||
return (
|
||||
<ListItem button onClick={handleClick}>
|
||||
<ListItemText primary={item} />
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(PopupListItem);
|
||||
Reference in New Issue
Block a user