MCPcopy Create free account
hub / github.com/bytebase/bytebase / useAppProject

Function useAppProject

frontend/src/react/hooks/useAppProject.ts:14–30  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

12 * legacy `useProjectV1Store().getProjectByName`.
13 */
14export const useAppProject = (name: string): Project => {
15 const getProjectByName = useAppStore((s) => s.getProjectByName);
16 const fetchProject = useAppStore((s) => s.fetchProject);
17 // Subscribe to the specific cache entry so the value recomputes once
18 // the project resolves. Selecting the raw entry (not the fallback)
19 // keeps the snapshot stable for `useSyncExternalStore`.
20 const cached = useAppStore((s) => s.projectsByName[name]);
21 useEffect(() => {
22 if (isValidProjectName(name)) {
23 void fetchProject(name);
24 }
25 }, [fetchProject, name]);
26 return useMemo(
27 () => getProjectByName(name),
28 [getProjectByName, name, cached]
29 );
30};

Callers 9

SQLEditorHomePageFunction · 0.90
RequestExportButtonFunction · 0.90
GutterBarFunction · 0.90
AccessPaneFunction · 0.90
WelcomeFunction · 0.90
SQLEditorRouteShellFunction · 0.90
RequestQueryButtonFunction · 0.90
MaskingReasonPopoverFunction · 0.90
ConnectionPaneInnerFunction · 0.90

Calls 3

isValidProjectNameFunction · 0.90
useAppStoreFunction · 0.50
getProjectByNameFunction · 0.50

Tested by

no test coverage detected