如何从文档中的主题示例访问 "admin" 对象?
How to access the "admin" object from Theming example in docs?
React-Admin 的“Theming”文档在某些示例中使用了以下代码行:
const open = useSelector(state => state.admin.ui.sidebarOpen);
它不能按原样工作。还需要做什么才能访问“sidebarOpen”属性?
这是 TypeScript 编译错误,这意味着您应该在该函数中禁用 TypeScript:
const open = useSelector((state: any) => state.admin.ui.sidebarOpen);
或为 react-admin 应用传递正确的 Redux 存储类型:
import { ReduxState } from 'react-admin';
const open = useSelector((state: ReduxState) => state.admin.ui.sidebarOpen);
React-Admin 的“Theming”文档在某些示例中使用了以下代码行:
const open = useSelector(state => state.admin.ui.sidebarOpen);
它不能按原样工作。还需要做什么才能访问“sidebarOpen”属性?
这是 TypeScript 编译错误,这意味着您应该在该函数中禁用 TypeScript:
const open = useSelector((state: any) => state.admin.ui.sidebarOpen);
或为 react-admin 应用传递正确的 Redux 存储类型:
import { ReduxState } from 'react-admin';
const open = useSelector((state: ReduxState) => state.admin.ui.sidebarOpen);