Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

px unit for grid gap discrepancy between preact-render-to-string and react-dom/server #218 #239

Open
jpnelson opened this issue Aug 19, 2022 · 0 comments

Comments

@jpnelson
Copy link

We've noticed a discrepancy in how preact / react server renders a component that looks like this:

import React from "preact/compat";
import "./styles.css";

export default function App() {
  return (
    <div
      style={{
        display: "grid",
        "grid-column-gap": 16,
        "grid-row-gap": 24,
        border: "1px solid red"
      }}
    >
      <div className="child">Child</div>
      <div className="child">Child</div>
      <div className="child">Child</div>
      <div className="child">Child</div>
    </div>
  );
}

Code sandboxes for preact and react to compare the output:

We're using React 16.14.0 but as far as I can tell, React 17.x would have the same discrepancy.

I think the difference is that in Preact, we use this regex:

IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;

Which would match grid-gap, but React explicitly lists non dimensional properties: https://github.com/facebook/react/blob/v17.0.0/packages/react-dom/src/shared/CSSProperty.js#L11

So properties that would be non dimensional in Preact but not React are:

  • gridRowGap
  • gridColumnGap

There might be more, it might be worth auditing gap properties fully to ensure there aren't more discrepancies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant