Skip to content

Commit

Permalink
Fix double log of AdminGuesser
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Nov 6, 2024
1 parent e430340 commit a133501
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import App from './App';
import reportWebVitals from './reportWebVitals';

const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(<App />);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react';
import { useAPISchema } from 'ra-supabase-core';
import type { ResourceProps } from 'react-admin';

Expand All @@ -8,11 +9,13 @@ import { ShowGuesser } from './ShowGuesser';

export const useCrudGuesser = () => {
const { data: schema, error, isPending } = useAPISchema();
let resourceDefinitions: ResourceProps[] = [];
if (!isPending && !error) {
return useMemo<ResourceProps[]>(() => {
if (isPending || error) {
return [];
}
let edit, show, create, list;
const resourceNames = Object.keys(schema.definitions!);
resourceDefinitions = resourceNames.map(name => {
return resourceNames.map(name => {
const resourcePaths = schema.paths[`/${name}`] ?? {};
if (resourcePaths.get) {
list = ListGuesser;
Expand All @@ -32,6 +35,5 @@ export const useCrudGuesser = () => {
create,
};
});
}
return resourceDefinitions;
}, [schema, isPending, error]);
};

0 comments on commit a133501

Please sign in to comment.