UNPKG

2.44 kBTypeScriptView Raw
1import * as React from 'react';
2import { AdminContextProps, AdminUIProps } from 'ra-ui-materialui';
3/**
4 * Main admin component, entry point to the application.
5 *
6 * Initializes the various contexts (auth, data, i18n, router)
7 * and defines the main routes.
8 *
9 * Expects a list of resources as children, or a function returning a list of
10 * resources based on the permissions.
11 *
12 * @example
13 *
14 * // static list of resources
15 *
16 * import {
17 * Admin,
18 * Resource,
19 * ListGuesser,
20 * useDataProvider,
21 * } from 'react-admin';
22 *
23 * const App = () => (
24 * <Admin dataProvider={myDataProvider}>
25 * <Resource name="posts" list={ListGuesser} />
26 * </Admin>
27 * );
28 *
29 * // dynamic list of resources based on permissions
30 *
31 * import {
32 * Admin,
33 * Resource,
34 * ListGuesser,
35 * useDataProvider,
36 * } from 'react-admin';
37 *
38 * const App = () => (
39 * <Admin dataProvider={myDataProvider}>
40 * {permissions => [
41 * <Resource name="posts" key="posts" list={ListGuesser} />,
42 * ]}
43 * </Admin>
44 * );
45 *
46 * // If you have to build a dynamic list of resources using a side effect,
47 * // you can't use <Admin>. But as it delegates to sub components,
48 * // it's relatively straightforward to replace it:
49 *
50 * import * as React from 'react';
51import { useEffect, useState } from 'react';
52 * import {
53 * AdminContext,
54 * AdminUI,
55 * defaultI18nProvider,
56 * localStorageStore,
57 * Resource,
58 * ListGuesser,
59 * useDataProvider,
60 * } from 'react-admin';
61 *
62 * const store = localStorageStore();
63 *
64 * const App = () => (
65 * <AdminContext dataProvider={myDataProvider} i18nProvider={defaultI18nProvider} store={store}>
66 * <Resources />
67 * </AdminContext>
68 * );
69 *
70 * const Resources = () => {
71 * const [resources, setResources] = useState([]);
72 * const dataProvider = useDataProvider();
73 * useEffect(() => {
74 * dataProvider.introspect().then(r => setResources(r));
75 * }, []);
76 *
77 * return (
78 * <AdminUI>
79 * {resources.map(resource => (
80 * <Resource name={resource.name} key={resource.key} list={ListGuesser} />
81 * ))}
82 * </AdminUI>
83 * );
84 * };
85 */
86export declare const Admin: (props: AdminProps) => React.JSX.Element;
87export default Admin;
88export interface AdminProps extends AdminContextProps, AdminUIProps {
89}
90//# sourceMappingURL=Admin.d.ts.map
\No newline at end of file