mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(app): avoid infinite render loop in FilePanel zustand selector
The selector returned a freshly constructed authority object each call, so useSyncExternalStore saw a new reference every render and force-rerendered, producing a maximum update depth crash. Select the specific workspace descriptor (stable reference) and derive the authority via useMemo.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useMemo } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { FileText } from "lucide-react-native";
|
||||
import invariant from "tiny-invariant";
|
||||
@@ -20,12 +21,10 @@ function useFilePanelDescriptor(target: { kind: "file"; path: string }) {
|
||||
|
||||
function FilePanel() {
|
||||
const { serverId, workspaceId, target } = usePaneContext();
|
||||
const authority = useSessionStore((state) =>
|
||||
resolveWorkspaceExecutionAuthority({
|
||||
workspaces: state.sessions[serverId]?.workspaces,
|
||||
workspaceId,
|
||||
}),
|
||||
const workspace = useSessionStore(
|
||||
(state) => state.sessions[serverId]?.workspaces.get(workspaceId) ?? null,
|
||||
);
|
||||
const authority = useMemo(() => resolveWorkspaceExecutionAuthority({ workspace }), [workspace]);
|
||||
invariant(target.kind === "file", "FilePanel requires file target");
|
||||
if (!authority) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user