Skip to content

Commit 7788a98

Browse files
fix: Only run initialization effect on first render
1 parent 834c755 commit 7788a98

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/UIRouter.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ export const InstanceOrPluginsMissingError = `Router instance or plugins missing
124124
*/
125125
export function UIRouter(props: UIRouterProps) {
126126
const uiRouter = useRef<UIRouterReact>();
127-
const [_hasStarted, start] = useState<boolean>(false);
127+
const [started, setStarted] = useState<boolean>(false);
128128

129129
useEffect(() => {
130-
// Router hasn't been initialised yet, this is the first render
131130
if (!uiRouter.current) {
131+
// Router hasn't been initialised yet, this is the first render
132132
const { config, states, plugins, router } = props;
133133
if (router) {
134134
uiRouter.current = router;
@@ -144,9 +144,9 @@ export function UIRouter(props: UIRouterProps) {
144144
}
145145

146146
uiRouter.current.start();
147-
start(true);
147+
setStarted(true);
148148
}
149-
});
149+
}, []);
150150

151151
return uiRouter.current ? (
152152
<UIRouterContext.Provider value={uiRouter.current}>{props.children}</UIRouterContext.Provider>

0 commit comments

Comments
 (0)