0

I'm trying to use bootstrap (specifically a theme from bootswatch) in my react app. I'm sorry if this has been answered elsewhere, but I've searched for an answer for several hours to no avail.

Right now, on smaller screens the bootstrap navbar collapses to a hamburger menu. When I click it nothing happens. When I used material UI I had to create a drawer element and set its open-property to the current state, and have an on-click handler to change that state.

<Drawer open={this.state.isOpen} onClose={this.handleDrawerClose}>

Do I need to do something similar for bootstrap, and in that case, which property am I supposed to change? Currently my navbar looks like this:

import React, { useState } from 'react';

export default function Navbar() {
    return (
        <nav className="navbar navbar-expand-lg navbar-dark bg-primary">
            <a className="navbar-brand ml-3" href="#">
                Cocktail Nightz
            </a>
            <button
                className="navbar-toggler"
                type="button"
                data-toggle="collapse"
                data-target="#navbar-toggle"
                aria-controls="nav-content"
                aria-expanded="false"
                aria-label="Toggle navigation"
            >
                <span className="navbar-toggler-icon" />
            </button>

            <div className="collapse navbar-collapse" id="navbar-toggle">
                <ul className="navbar-nav mr-auto">
                    <li className="nav-item active">
                        <a className="nav-link" href="#">
                            Home <span className="sr-only">(current)</span>
                        </a>
                    </li>
                    <li className="nav-item">
                        <a className="nav-link" href="#">
                            Cocktail
                        </a>
                    </li>
                    <li className="nav-item">
                        <a className="nav-link" href="#">
                            Meal
                        </a>
                    </li>
                    <li className="nav-item">
                        <a className="nav-link" href="#">
                            About
                        </a>
                    </li>
                </ul>
            </div>
        </nav>
    );
}

I really appreciate any help!

ZeGeR
  • 51
  • 3
  • 10
  • Did you check the last example from [this page](https://www.w3schools.com/bootstrap/bootstrap_navbar.asp)? – leverglowh Jan 16 '20 at 17:17
  • Yes, I did. I think that this is an issue when using it in React, and they don't do that in the examples at that page. – ZeGeR Jan 16 '20 at 17:47
  • 3
    I think as the answers say in this [question](https://stackoverflow.com/questions/53941329/use-bootstrap-4-with-react) you should checkout [reactstrap](https://reactstrap.github.io). So use `` instead of `` etc. – leverglowh Jan 16 '20 at 20:44
  • Thanks, leverglowh! I did just that and it works great now with reactstrap. =) – ZeGeR Jan 17 '20 at 08:40

0 Answers0