Skip to content

Instantly share code, notes, and snippets.

@fabe
Created April 13, 2016 10:31
Show Gist options
  • Save fabe/adff501602c64ef383bc08dddc8d503e to your computer and use it in GitHub Desktop.
Save fabe/adff501602c64ef383bc08dddc8d503e to your computer and use it in GitHub Desktop.
Simple two column masonry layout for React
import React from 'react';
class Columns extends React.Component {
render() {
var columnFirst = []
var columnSecond = []
this.props.nodes.map(function(node, index) {
if(index % 2 == 0) {
columnFirst.push(node)
} else {
columnSecond.push(node)
}
})
return (
<div className="columns">
<div className="column first">
{columnFirst}
</div>
<div className="column second">
{columnSecond}
</div>
</div>
);
}
};
module.exports = Columns;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment