Skip to content

Commit

Permalink
fix removeeventlistener calls to point to same function
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 committed Feb 23, 2024
1 parent 6678799 commit 0b8426d
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,23 @@ function App() {
const [showInstallButton, setShowInstallButton] = React.useState(true);

React.useEffect(() => {
window.addEventListener("beforeinstallprompt", (event) =>
const listener = (event) =>
handleBeforeInstallPrompt(
event,
setInstallPromptEvent,
setShowInstallButton,
),
);
return () =>
window.removeEventListener("beforeinstallprompt", (event) =>
handleBeforeInstallPrompt(
event,
setInstallPromptEvent,
setShowInstallButton,
),
);

window.addEventListener("beforeinstallprompt", listener);
return () => window.removeEventListener("beforeinstallprompt", listener);
}, []);

React.useEffect(() => {
window.addEventListener("appinstalled", () =>
handleAppInstalled(setInstallPromptEvent, setShowInstallButton),
);
return () => window.removeEventListener("appinstalled", handleAppInstalled);
const listener = () =>
handleAppInstalled(setInstallPromptEvent, setShowInstallButton);

window.addEventListener("appinstalled", listener);
return () => window.removeEventListener("appinstalled", listener);
}, []);

React.useLayoutEffect(() => {
Expand Down

0 comments on commit 0b8426d

Please sign in to comment.