ShowController with TabbedShowLayout
up vote
0
down vote
favorite
I am actually doing a dashboard using React-Admin, and I discovered the <ShowController> who permits to use Material-UI components inside the Show View.
But my problem comes here, I used a <TabbedShowLayout> and it doesn't work really well. Let me explain :
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<div>
<TextField source="id" />
</div>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
Here is my actual code, and it displays nothing except the tab with the icon.
But if i remove the <div> component, it works.
I would like to know, if someone ever does that, and made it works.
Thanks by advance
react-admin
add a comment |
up vote
0
down vote
favorite
I am actually doing a dashboard using React-Admin, and I discovered the <ShowController> who permits to use Material-UI components inside the Show View.
But my problem comes here, I used a <TabbedShowLayout> and it doesn't work really well. Let me explain :
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<div>
<TextField source="id" />
</div>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
Here is my actual code, and it displays nothing except the tab with the icon.
But if i remove the <div> component, it works.
I would like to know, if someone ever does that, and made it works.
Thanks by advance
react-admin
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am actually doing a dashboard using React-Admin, and I discovered the <ShowController> who permits to use Material-UI components inside the Show View.
But my problem comes here, I used a <TabbedShowLayout> and it doesn't work really well. Let me explain :
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<div>
<TextField source="id" />
</div>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
Here is my actual code, and it displays nothing except the tab with the icon.
But if i remove the <div> component, it works.
I would like to know, if someone ever does that, and made it works.
Thanks by advance
react-admin
I am actually doing a dashboard using React-Admin, and I discovered the <ShowController> who permits to use Material-UI components inside the Show View.
But my problem comes here, I used a <TabbedShowLayout> and it doesn't work really well. Let me explain :
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<div>
<TextField source="id" />
</div>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
Here is my actual code, and it displays nothing except the tab with the icon.
But if i remove the <div> component, it works.
I would like to know, if someone ever does that, and made it works.
Thanks by advance
react-admin
react-admin
asked Nov 9 at 12:27
asa
17612
17612
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The reason is properties inheritance is not "native", you have to do it manually. react-admin is doing it in each component.
When you insert a div element in a react-admin form or layout, you break this inheritance between Tab and TextField. The div is receiving props from parent Tab, but doesn't forward them to TextField.
One solution is to make a custom wrapper. In your case:
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<CustomDiv>
<TextField source="id" />
</CusomDiv>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
With
const CustomDiv = ({children, ...props}) => (
<div>
{
React.Children.map(children, child => React.cloneElement(child, {...props, ...child.props}))
}
</div>
);
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The reason is properties inheritance is not "native", you have to do it manually. react-admin is doing it in each component.
When you insert a div element in a react-admin form or layout, you break this inheritance between Tab and TextField. The div is receiving props from parent Tab, but doesn't forward them to TextField.
One solution is to make a custom wrapper. In your case:
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<CustomDiv>
<TextField source="id" />
</CusomDiv>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
With
const CustomDiv = ({children, ...props}) => (
<div>
{
React.Children.map(children, child => React.cloneElement(child, {...props, ...child.props}))
}
</div>
);
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
add a comment |
up vote
1
down vote
accepted
The reason is properties inheritance is not "native", you have to do it manually. react-admin is doing it in each component.
When you insert a div element in a react-admin form or layout, you break this inheritance between Tab and TextField. The div is receiving props from parent Tab, but doesn't forward them to TextField.
One solution is to make a custom wrapper. In your case:
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<CustomDiv>
<TextField source="id" />
</CusomDiv>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
With
const CustomDiv = ({children, ...props}) => (
<div>
{
React.Children.map(children, child => React.cloneElement(child, {...props, ...child.props}))
}
</div>
);
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The reason is properties inheritance is not "native", you have to do it manually. react-admin is doing it in each component.
When you insert a div element in a react-admin form or layout, you break this inheritance between Tab and TextField. The div is receiving props from parent Tab, but doesn't forward them to TextField.
One solution is to make a custom wrapper. In your case:
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<CustomDiv>
<TextField source="id" />
</CusomDiv>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
With
const CustomDiv = ({children, ...props}) => (
<div>
{
React.Children.map(children, child => React.cloneElement(child, {...props, ...child.props}))
}
</div>
);
The reason is properties inheritance is not "native", you have to do it manually. react-admin is doing it in each component.
When you insert a div element in a react-admin form or layout, you break this inheritance between Tab and TextField. The div is receiving props from parent Tab, but doesn't forward them to TextField.
One solution is to make a custom wrapper. In your case:
<ShowController {...props}>
{controllerProps =>
<ShowView {...props} {...controllerProps}>
<TabbedShowLayout {...controllerProps}>
<Tab icon={<AssignIcon />}>
<CustomDiv>
<TextField source="id" />
</CusomDiv>
</Tab>
</TabbedShowLayout>
</ShowView>
}
</ShowController>
With
const CustomDiv = ({children, ...props}) => (
<div>
{
React.Children.map(children, child => React.cloneElement(child, {...props, ...child.props}))
}
</div>
);
edited Nov 12 at 10:27
answered Nov 12 at 9:44
despatates
537
537
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
add a comment |
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
Thanks a lot for your answer, it helps me a lot to understand.
– asa
Nov 12 at 10:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225722%2fshowcontroller-with-tabbedshowlayout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown