Now that CSS grid is out and we're finally able to implement sites semantically and lay out stuff nicely without enormous amounts of divs and hacks it would be very nice to see this principle followed in frameworks such as next.js. Unfortunately that's not the case at the moment.
I'm currently following the tutorial and I already have....
<body>
<div>
<div id="__next">
<div data-reactroot="" data-reactid="1" data-react-checksum="315191458">
<!-- my content full of wrapper divs because of react.js -->
</div>
<div id="__next-error"><!-- guess this exists only in dev mode -->
</div>
</div>
<div>
<script>...</script>
...
</div>
<script>...</script>
</body>
I think only div we should have is the react root div.
I see a few unnecessary looking divs.
Using Bootstrap themes is really difficult because of this. Especially when one needs to use styles like "height:100%" on first child "div" after body.
Added this to normalize:
body>div, #__next, #__next>div, #__next>div>div {
height: 100%;
}
Not sure how CSS Grids is related to this but I'm pretty sure now with React v16 we could get rid of the div with the ID __next
and just render an array, what do you think @timneutkens?
@sergiodxa You're right 馃憤
would recommend a small edit to the workaround by @lancejpollard:
/* normalize divs surrounding the content*/
body > div:first-child,
#__next,
#__next > div,
#__next > div > div {
height: 100%;
}
This is to avoid the #__next-error div blowing up to 100% as well.
This is pretty darn hacky though. :( I would rlly appreciate it if the div inside of body could at least have a className, so I don't have to try to target it using body > div:first-child which feels bad to do
@laurajuliette Thank you for a quick hack, it would indeed be nice if the divs had classes so you could make them 100% height easier
Why can't this be adjusted? I don't see the point for generating the divs. The new React fragment syntax should also be possible to use:
class X extends React.Component {
render() {
return (
<>
<td>Hello</td>
<td>World</td>
</>
);
}
}
Fixed in canary. <>
can't be used yet because it requires the beta version of babel. Which we'll integrate in next.js v6.
Most helpful comment
would recommend a small edit to the workaround by @lancejpollard:
This is to avoid the #__next-error div blowing up to 100% as well.
This is pretty darn hacky though. :( I would rlly appreciate it if the div inside of body could at least have a className, so I don't have to try to target it using body > div:first-child which feels bad to do