如何在没有默认appLayout的情况下删除以下警告或以其他方式在react-admin中添加自定义路由?
警告:您不应在其中使用
<Route component>
和<Route render>
相同的路线;<Route render>
将被忽略
import React, { Component } from 'react';
import { Admin, Resource } from 'react-admin';
import { Route } from 'react-router-dom';
import restProvider from 'ra-data-simple-rest';
class App extends Component {
render() {
return (
<Admin
title="react-admin"
dataProvider={restProvider('http://localhost:3000')}
customRoutes={[<Route exact path="/custom" component={()=><div>Custom page without layout</div>} noLayout /> ]}
>
<Resource name="test" list={() => <div>Test Resource</div>} />
</Admin>
);
}
}
export default App;
答案 0 :(得分:0)
在路径中使用子项代替组件:
class App extends Component {
render() {
return (
<Admin
title="react-admin"
dataProvider={restProvider('http://localhost:3000')}
customRoutes={[<Route exact path="/custom" noLayout><div>Custom page without layout</div></Route>]}
>
<Resource name="test" list={() => <div>Test Resource</div>} />
</Admin>
);
}
}
export default App;