Skip to content

Commit

Permalink
Merge pull request #10 from edoroshenko/fix-server-side-rendering
Browse files Browse the repository at this point in the history
Fix SSR
  • Loading branch information
Cédric Delpoux authored Dec 12, 2017
2 parents 667e1f2 + 23c5cac commit 75edd82
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "lts/*"
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.3",
"jest": "^21.2.1",
"npmpub": "^3.1.0",
"prop-types": "^15.5.8",
"react": "^16.0.0"
"react": "^16.0.0",
"react-dom": "^16.1.1"
},
"peerDependencies": {
"prop-types": "^15.5.0",
Expand All @@ -37,8 +39,9 @@
"scripts": {
"clean": "rm -rf lib",
"lint": "eslint src/",
"build": "babel ./src --out-dir ./lib --source-maps -d ./lib",
"build": "babel ./src --out-dir ./lib --source-maps -d ./lib --ignore spec.js",
"prepublish": "npm run clean && npm run build",
"release": "npmpub"
"release": "npmpub",
"test": "jest"
}
}
2 changes: 1 addition & 1 deletion src/ResponsiveMasonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MasonryResponsive extends React.Component {
super(props)

this.state = {
columnsCount: null,
columnsCount: DEFAULT_COLUMNS_COUNT,
}

this.handleResize = this.handleResize.bind(this)
Expand Down
14 changes: 14 additions & 0 deletions src/__tests__/ResponsiveMasonry.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { renderToString } from 'react-dom/server';
import Masonry, { ResponsiveMasonry } from '../';

describe('server-side rendering', () => {
it('should render on server', () => {
const content = 'Custom content inside ResponsiveMasonry wrapper';
const result = renderToString(<ResponsiveMasonry>
<Masonry><div>{content}</div></Masonry>
</ResponsiveMasonry>);

expect(result.match(RegExp(content))).not.toBeNull();
})
});

0 comments on commit 75edd82

Please sign in to comment.