反应管理员:无法读取未定义的属性“过滤器”

时间:2019-02-21 00:06:00

标签: docker production-environment react-admin api-platform.com

我将react adminAPI Platform admin一起使用,但我不知道为什么在生产中会出现此错误,但在本地docker环境中却没有:

enter image description here

react-dom.production.min.js:3282 
TypeError: Cannot read property 'filter' of undefined
    at l (fieldFactory.js:21)
    at p (List.js:83)
    at beginWork (react-dom.production.min.js:2902)
    at o (react-dom.production.min.js:4051)
    at a (react-dom.production.min.js:4068)
    at x (react-dom.production.min.js:4296)
    at w (react-dom.production.min.js:4263)
    at b (react-dom.production.min.js:4254)
    at interactiveUpdates (react-dom.production.min.js:4563)
    at xn (react-dom.production.min.js:1684)

我正在使用demo example,不知道是哪个元素导致了此问题:是否有办法知道哪个元素导致了错误?

1 个答案:

答案 0 :(得分:1)

原来的错误是我错误地提供了in the demo所示的自定义路由,然后使用API​​平台的authentication example来设置这些自定义路由:

            switch (result.status) {
                case 401:
                    return Promise.resolve({
                        api: result.api,
                        customRoutes: [{
                            props: {
                                path: '/',
                                render: () => <Redirect to={`/login`}/>,
                            },
                        }],
                    });

                default:
                    return Promise.reject(result);
            }
...
            <HydraAdmin
                title=""
                dataProvider={dataProvider}
                customReducers={{ theme: themeReducer }}
                customSagas={sagas}
                customRoutes={customRoutes}
                authProvider={authProvider}
                dashboard={Dashboard}
                loginPage={Login}
                appLayout={Layout}
                menu={Menu}
                locale="en"
                i18nProvider={i18nProvider}
            >
...

向API平台提供错误的路由会触发该错误。因此我通过删除自定义路由来解决它:customRoutes={customRoutes}