Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

JUAN VARGAS
JUAN VARGAS
17,801 Points

How to build a masonry grid in a Reactjs website-app

My problem is that the layout is breaking into two columns I want 3 max and down from there. I want to practice as much as I can but got stuck on this one!

import React, { Component } from 'react'; import Masonry from 'react-masonry-component';

class HomePage extends Component { constructor(props) { super(props); this.state = { hasMore: true }; }

render() { return ( <div className="container">

      <Masonry
        className="posts"
        elementType="ul"
      >


        <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/one.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        FEBRUARY 10 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">Bureaux exquisite 
                    delightful carefully 
                    curated soft
                    power.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}
            <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/two.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        FEBRUARY 2 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">Sharp bureaux sleepy K-pop carefully curated.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}
            <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/three.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        JANUARY 27 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">St Moritz uniforms Beams.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}
            <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/four.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        JANUARY 21 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">Esse airport veniam ryokan soft power.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}
            <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/five.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        JANUARY 18 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">K-pop extraordinary.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}
            <li className="post--item">
                <div className="post--img">
                    <img src={require('./../../assets/images/posts/six.jpg')} />
                </div>
                <div className="post--date">
                    <span>
                        JANUARY 12 2017
                    </span>
                </div>

                <h2 className="post--title">
                    <a href="./">Artisanal iconic cutting-edge business class.</a>
                </h2>
                <div className="post--presenter">
                    Presented by <a href="#">lorem ipsum</a>
                </div>
            </li>   
            {/* end of post item */}                 
     </Masonry>

    </div>
);

} }

export default HomePage;

1 Answer

JUAN VARGAS
JUAN VARGAS
17,801 Points

I solved the problem if someone is trying to do the same layout let me know!