Skip to content

Commit 8fecd5b

Browse files
Fix lint issues
1 parent 5e7d868 commit 8fecd5b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useState } from "react";
22
import "./App.css";
33
import { IonApp, IonPage, IonRouterOutlet } from "@ionic/react";
44
import { IonReactRouter } from "@ionic/react-router";

src/NavigateOnStateChange.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useIonRouter } from "@ionic/react";
2-
import React, { useContext, useEffect } from "react";
2+
import React, { useEffect } from "react";
33

44
type NavigateOnStateChangeProps = { route?: string, onNavigate?: () => void}
55

66
export const NavigateOnStateChange: React.FC<NavigateOnStateChangeProps> = ({route, onNavigate}) => {
77
const ionRouter = useIonRouter();
88
console.log("NavigateOnStateChange", ionRouter);
99
useEffect(() => {
10-
if (route) {
10+
if (route && ionRouter) {
1111
console.log("Route changed ", route);
1212
setTimeout(() => {
1313
ionRouter.push(route);
@@ -16,6 +16,8 @@ export const NavigateOnStateChange: React.FC<NavigateOnStateChangeProps> = ({rou
1616
onNavigate();
1717
}
1818
}
19+
/* This useEffect should ONLY run when route changes */
20+
// eslint-disable-next-line react-hooks/exhaustive-deps
1921
}, [route]);
2022
return <></>
2123
}

0 commit comments

Comments
 (0)