Indeed, I am using api platform to develop an api with Symfony. However, when I want to generate an admin interface using api platform/admin and react-admin, I receive this error in my console:
@api-platform_admin.js?v=5df60b07:115027 Uncaught TypeError: Cannot read properties of undefined (reading 'mode') at ToggleThemeLegacyButton (@api-platform_admin.js?v=5df60b07:115027:97) at renderWithHooks (chunk-KXIZOLV7.js?v=5df60b07:12169:26) at mountIndeterminateComponent (chunk-KXIZOLV7.js?v=5df60b07:14919:21) at beginWork (chunk-KXIZOLV7.js?v=5df60b07:15900:22) at HTMLUnknownElement.callCallback2 (chunk-KXIZOLV7.js?v=5df60b07:3672:22) at Object.invokeGuardedCallbackDev (chunk-KXIZOLV7.js?v=5df60b07:3697:24) at invokeGuardedCallback (chunk-KXIZOLV7.js?v=5df60b07:3731:39) at beginWork$1 (chunk-KXIZOLV7.js?v=5df60b07:19759:15) at performUnitOfWork (chunk-KXIZOLV7.js?v=5df60b07:19192:20) at workLoopSync (chunk-KXIZOLV7.js?v=5df60b07:19131:13)
And here is my App.tsx file:
import { HydraAdmin } from "@api-platform/admin";
export const App = () => (
<HydraAdmin entrypoint="http://localhost:8000/api" >
</HydraAdmin>
);
I have followed again and again what is in the api platform documentation but to no avail.
I found the solution to this.
There is a bug in that ToggleThemeLegacyButton class. If you look at its docs, you'll see it it deprecated. To avoid the problem you have to pass the lightTheme and darkTheme props in explicitly. Here is my App.js:
And if you're using TypeScript, use this: