Skip to content

Commit

Permalink
fix: Navigo kept adding listeners (#19)
Browse files Browse the repository at this point in the history
Anytime the URL changed we added a new listener. This lead to confusion.
  • Loading branch information
arv authored Mar 19, 2024
1 parent 5e402ab commit af3f055
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions client/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ const App = ({
const [listID, setListID] = useState('');
const [showingShare, setShowingShare] = useState(false);

router.on('/list/:listID', match => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const {data} = match!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const {listID} = data!;
setListID(listID);
useEffect(() => {
router.on('/list/:listID', match => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const {data} = match!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const {listID} = data!;
setListID(listID);
});
return () => {
router.off('/list/:listID');
};
});

useEffect(() => {
router.resolve();
}, []);
Expand Down

0 comments on commit af3f055

Please sign in to comment.