Andrew Python
Andrew Python

Reputation: 67

Bootstrap rows/columns not working in React app

While following a tutorial video, I encountered an issue with the rows and columns classes in bootstrap.

The instructor in the video made a div with a row class and al the items seemed to work perfectly. When trying to duplicate the same things, all my items just stack on top of each other in a single column rather than multiple. Even when the browser is at full screen.

Here is the link to the video (https://www.youtube.com/watch?v=-edmQKcOW8s&t=19375s) @ 1:51:52 is where the problem occurs

Any help would be greatly appreciated

export default class ProductList extends Component {
  render() {
    return (
      <React.Fragment>
        <div className="py-5">
          <div className="container">
            <Title name="our" title="products" />
            <div classname="row">
                <ProductConsumer>
                  {value => {
                    return value.products.map(product => {
                      return <Product key={product.id} product=
                      {product} />
                    })
                  }}
                </ProductConsumer>
              </div>
            </div>
          </div>
      </React.Fragment>
    )
  }
}

Expected result would be that on a full screen browser items would be listed in 4 columns.

Upvotes: 0

Views: 563

Answers (1)

user9408899
user9408899

Reputation: 4540

  <div classname="row">

You have a typo here. It should be className.

Secondly, there is no col class in your code. Try adding this:

return(
    <div className="col-3">
        <Product key={product.id} product={product} />
    </div>
)

Upvotes: 1

Related Questions