React.NET icon indicating copy to clipboard operation
React.NET copied to clipboard

Need a way to use Html.React without inserting wrapper element

Open screaney opened this issue 8 years ago • 2 comments

I'm attempting to use MDL with React. My layout is: <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header"> @Html.React("LayoutHeader", new { pageModel = headerModel }, "header", containerClass: "mdl-layout__header") @Html.React("LayoutDrawer", new { pageModel = headerModel }) <main class="mdl-layout__content"></main> </div>

MDL requires it's elements to be direct children, like so: <div layout> <header> <drawer> <content> </div layout>

I was able to make the header component work since the MDL template had an element I could wrap, however, the drawer only has one element, then multiple children (which I can't do within the Render() method).

Is there a way to have HTML.React output the render directly without inserting a wrapper element?

screaney avatar Apr 13 '18 19:04 screaney

The common solution to this in React is to render() multiple children in a simple <div></div>. See if that works.

etherwizard avatar Apr 30 '18 20:04 etherwizard

Yeah, you'll probably need to wrap the children in a div, as noted above.

dustinsoftware avatar May 16 '18 15:05 dustinsoftware