fix rerenders (#6272)

This commit is contained in:
Jack Kavanagh 2023-08-14 20:34:29 +02:00 committed by GitHub
parent 3eedddc073
commit bd23cfeb69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -29,7 +29,7 @@ import { Pane, PaneHeader } from './pane';
import { PlaceholderResponsePane } from './placeholder-response-pane';
interface Props {
runningRequests: Record<string, number>;
runningRequests: Record<string, boolean>;
}
export const ResponsePane: FC<Props> = ({
runningRequests,

View File

@ -109,13 +109,15 @@ export const Debug: FC = () => {
settings,
} = useRouteLoaderData('root') as RootLoaderData;
const { sidebarFilter } = activeWorkspaceMeta;
const [runningRequests, setRunningRequests] = useState({});
const [runningRequests, setRunningRequests] = useState<Record<string, boolean>>({});
const setLoading = (isLoading: boolean) => {
invariant(requestId, 'No active request');
setRunningRequests({
...runningRequests,
[requestId]: isLoading ? true : false,
});
if (runningRequests?.[requestId] !== isLoading) {
setRunningRequests({
...runningRequests,
[requestId]: isLoading ? true : false,
});
}
};
const grpcState = grpcStates.find(s => s.requestId === requestId);