Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!