From 367d7294b84030c967fd29dd3933a92add93bf44 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 25 Feb 2021 08:30:23 +0100 Subject: [PATCH] Enable refetch on focus (#1559) During the integration of react-query we had to disable the refetch on focus option, because it has cleared our input fields on refocusing the browser tab. This problem comes mostly from a wrong use of routes. Often routes were used with the component prop and a anonymous function e.g.: ```jsx } /> ``` This triggers not only rerendering but remounting of the route component every time the parent is rerendered. With the ongoing work on the migration from redux to react-query, we have removed the usage of routes with component functions. So we can now safely enable the option refetch on mount of react-query. --- scm-ui/ui-api/src/ApiProvider.tsx | 4 +--- scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scm-ui/ui-api/src/ApiProvider.tsx b/scm-ui/ui-api/src/ApiProvider.tsx index fe18a73166..50e9a05cb2 100644 --- a/scm-ui/ui-api/src/ApiProvider.tsx +++ b/scm-ui/ui-api/src/ApiProvider.tsx @@ -31,9 +31,7 @@ import { reset } from "./reset"; const queryClient = new QueryClient({ defaultOptions: { queries: { - retry: false, - // refetch on focus can reset form inputs - refetchOnWindowFocus: false + retry: false } } }); diff --git a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx index ec07da7963..090636b1cb 100644 --- a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx @@ -22,7 +22,7 @@ * SOFTWARE. */ import React from "react"; -import { Redirect, Route, Link as RouteLink, Switch, useRouteMatch, match } from "react-router-dom"; +import { Redirect, Route, Link as RouteLink, Switch, useRouteMatch } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { binder, ExtensionPoint } from "@scm-manager/ui-extensions"; import { Changeset, Link } from "@scm-manager/ui-types"; @@ -245,7 +245,9 @@ const RepositoryRoot = () => { - } /> + + +