ShowController with TabbedShowLayout












0














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










share|improve this question



























    0














    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










    share|improve this question

























      0












      0








      0


      1





      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










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 '18 at 12:27









      asaasa

      17612




      17612
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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>
          );





          share|improve this answer























          • Thanks a lot for your answer, it helps me a lot to understand.
            – asa
            Nov 12 '18 at 10:20











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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>
          );





          share|improve this answer























          • Thanks a lot for your answer, it helps me a lot to understand.
            – asa
            Nov 12 '18 at 10:20
















          1














          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>
          );





          share|improve this answer























          • Thanks a lot for your answer, it helps me a lot to understand.
            – asa
            Nov 12 '18 at 10:20














          1












          1








          1






          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>
          );





          share|improve this answer














          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>
          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '18 at 10:27

























          answered Nov 12 '18 at 9:44









          despatatesdespatates

          537




          537












          • Thanks a lot for your answer, it helps me a lot to understand.
            – asa
            Nov 12 '18 at 10:20


















          • Thanks a lot for your answer, it helps me a lot to understand.
            – asa
            Nov 12 '18 at 10:20
















          Thanks a lot for your answer, it helps me a lot to understand.
          – asa
          Nov 12 '18 at 10:20




          Thanks a lot for your answer, it helps me a lot to understand.
          – asa
          Nov 12 '18 at 10:20


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ