I am using react-admin previously admin-on-rest. I want to create a custom page that doesn't show the Menu sidebar, like Login page. I will use this page reset user's password. How can I do that?
-
https://marmelab.com/react-admin/Admin.html#applayout – Christiaan Westerbeek Jul 10 '18 at 14:47
-
I don't want to change all my Layout . I just want to create a page that is not in the react-admin layout – thecassion Jul 10 '18 at 15:04
-
You can achieve this using custom menu. – Ashim Saha Jul 10 '18 at 21:51
-
Thanks for your answer . I already have a custom Menu. I just want to have a page like login page to reset a user password. – thecassion Jul 11 '18 at 07:55
4 Answers
This is not obvious in the documentation but the Route actually accepts a noLayout prop:
<Admin
customRoutes={[
<Route
path="/custom"
component={CustomRouteNoLayout}
noLayout
/>,
<Route
path="/custom2"
component={CustomRouteWithLayout}
/>,
]}
>
- 6,966
- 3
- 15
- 29
-
v4 now has the following in their documentation: ```Tip: In previous versions of react-admin, you had to write
instead of – Valera Tumash Feb 06 '22 at 09:29. The former still works in Js projects but TypeScript won’t compile it.``` So you need to change that unless you are using .js
Add a custom route with the component you want to render. When route is successful the specified component will be presented. No Menu will be shown just whatever you have in the component you send as prop to Route.
The way you put the question it seemed like you were trying to have a custom page that hadn't a MenuItemLink in Menu. Had to reread the question to understand what you wanted.
- 317
- 3
- 12
I'd like to add on to Gildas Garcia's answer. After you added the customed routes as shown in the documentation, you need to add a hash # in front of the route url to be able to view the content.
For example, if you are displaying the view at localhost:3000/, and one of your routes is
<Route exact path="/foo" component={Foo} />,
then you should go to localhost:3000/#/foo to view the content.
- 441
- 1
- 5
- 13
-
1If anyone knows how to get rid of the hash `#` in the url please let me know! – Darius Jan 15 '19 at 09:02
-
It depends on the router history you're using. You can pass your own to react-admin – Gildas Garcia May 28 '19 at 06:00
As per current documentation (v4.12.1) you can use the noLayout property available in the CustomRoutes component:
const App = () => (
<Admin dataProvider={dataProvider}>
<CustomRoutes noLayout>
<Route path="/register" element={<Register />} />
</CustomRoutes>
<CustomRoutes>
<Route path="/settings" element={<Settings />} />
<Route path="/profile" element={<Profile />} />
</CustomRoutes>
</Admin>
);
- 86
- 1
- 7