在将noLayout属性添加到react-admin中的自定义路由列表时收到警告

时间:2019-03-08 08:14:51

标签: react-router-dom react-admin

如何在没有默认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;

1 个答案:

答案 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;