Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
Reactstrap navbar toggle not toggling in NextJS TypeScript project

I've installed Reactstrap on a project using the NextJS TypeScript install. I've copied the Navbar example from the Reactstrap docs. The navigation shows fine, but on mobile when I click the Navbar toggle, the toggle menu does not open. In fact, no JavaScript components from Reactstrap worked. I've tried modals as well, they don't work either.

Aside from the JavaScript not working when using the Reactstrap components, the Reactstrap CSS styles work completely fine.

Link to live project codesandbox to test.

Code for the Navbar specifically below:

import Link from "next/link";
import {
  NavbarBrand,
  NavbarToggler,
  Collapse,
  NavItem,
  NavLink,
  Nav,
  Navbar,
} from "reactstrap";

import styles from "./Navigation.module.scss";

const Navigation = () => {
  return (
    <div className={styles.nav}>
      <Navbar expand="md">
        <NavbarBrand href="/">Premium Delivery</NavbarBrand>
        <NavbarToggler onClick={function noRefCheck() {}} />
        <Collapse navbar>
          <Nav className="ms-auto" navbar>
            <NavItem>
              <NavLink>
                <Link href="/">Home</Link>
              </NavLink>
            </NavItem>
            <NavItem>
              <NavLink>
                <Link href="/services">Services</Link>
              </NavLink>
            </NavItem>
            <NavItem>
              <NavLink>
                <Link href="/service-fees">Service Fees</Link>
              </NavLink>
            </NavItem>
            <NavItem>
              <NavLink>
                <Link href="/about">About</Link>
              </NavLink>
            </NavItem>
            <NavItem>
              <NavLink>
                <Link href="/contact">Contact</Link>
              </NavLink>
            </NavItem>
          </Nav>
        </Collapse>
      </Navbar>
    </div>
  );
};

export default Navigation;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't know why, but their documentation on the Storybook puts the function noRefCheck() as a placeholder. You are meant to create your own function to activate the Reactstrap code as described in their Github examples: https://github.com/reactstrap/reactstrap/blob/master/stories/examples/NavbarToggler.js

First, import useState so we can use the hook. import { useState } from 'react';

Somewhere before the return, add a hook like const [isOpen, setIsOpen] = useState(false);

Next, for the NavbarToggle, add the hook to the Event <NavbarToggler onClick={() => { setIsOpen(!isOpen) }} />

Finally, ensure that the Collapse has the correct state

<Collapse isOpen={isOpen} navbar>
Navbar Contents
</Collapse>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda