(name: string)
| 1649 | }) |
| 1650 | |
| 1651 | const useModal = (name: string) => { |
| 1652 | const currentOpen = postRoute.useSearch({ |
| 1653 | select: (search) => search[`_${name}`], |
| 1654 | }) |
| 1655 | |
| 1656 | const navigate = useNavigate() |
| 1657 | |
| 1658 | const setModal = React.useCallback( |
| 1659 | (open: boolean) => { |
| 1660 | navigate({ |
| 1661 | to: '.', |
| 1662 | search: (prev: {}) => ({ |
| 1663 | ...prev, |
| 1664 | [`_${name}`]: open ? true : undefined, |
| 1665 | }), |
| 1666 | resetScroll: false, |
| 1667 | }) |
| 1668 | }, |
| 1669 | [name, navigate], |
| 1670 | ) |
| 1671 | |
| 1672 | return [currentOpen, setModal] as const |
| 1673 | } |
| 1674 | |
| 1675 | function DetailComponent(props: { id: string }) { |
| 1676 | const params = useParams({ strict: false }) |
no test coverage detected