Created
April 13, 2016 10:31
-
-
Save fabe/adff501602c64ef383bc08dddc8d503e to your computer and use it in GitHub Desktop.
Simple two column masonry layout for React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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