diff --git a/source/Grid/Grid.ssr.js b/source/Grid/Grid.ssr.js new file mode 100644 index 000000000..3d11d0ab7 --- /dev/null +++ b/source/Grid/Grid.ssr.js @@ -0,0 +1,33 @@ +/** + * @flow + * @jest-environment node + */ + +import React from "react"; +import ReactDOMServer from "react-dom/server"; +import Grid from "./Grid"; + +declare var test: any; +declare var expect: any; + +test("should render Grid with dom server", () => { + const rendered = ReactDOMServer.renderToString( + ( +
+ {rowIndex + ":" + columnIndex} +
+ )} + columnCount={1000} + columnWidth={20} + height={500} + rowCount={1000} + rowHeight={20} + width={500} + /> + ); + + expect(rendered).toContain("0:0"); + expect(rendered).toContain("24:24"); + expect(rendered).not.toContain("25:25"); +}); diff --git a/source/Grid/utils/maxElementSize.js b/source/Grid/utils/maxElementSize.js index 824f4ddfe..c5a7ea001 100644 --- a/source/Grid/utils/maxElementSize.js +++ b/source/Grid/utils/maxElementSize.js @@ -3,12 +3,15 @@ const DEFAULT_MAX_ELEMENT_SIZE = 1500000; const CHROME_MAX_ELEMENT_SIZE = 1.67771e7; +const isBrowser = () => typeof window !== "undefined"; + const isChrome = () => !!window.chrome && !!window.chrome.webstore; export const getMaxElementSize = (): number => { - if (isChrome()) { - return CHROME_MAX_ELEMENT_SIZE; + if (isBrowser()) { + if (isChrome()) { + return CHROME_MAX_ELEMENT_SIZE; + } } - return DEFAULT_MAX_ELEMENT_SIZE; };