Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
React Responsive Navbar and Slider Menu - issue with translateX

I'm trying to create a responsive navbar with a slider menu. I got everything working the way I want it to except for when maximizing the window (after closing the slide menu).

menu slider // Regular Responsive Nav {maximized window result after leaving menu slider open } // Responsive Nav {maximized window result after menu slider closed

    import "./App.css";
import React, { useState } from "react";
import { IconContext } from "react-icons";
import { GiHamburgerMenu } from "react-icons/gi";
import ProfileButtons from "./components/ProfileButtons";

function App() {
  let [isMenuOpen, setIsMenuOpen] = useState(false);
  let [menu, setMenu] = useState("translateX(0%)");

  function openMenu() {
    setIsMenuOpen(!isMenuOpen);
    if (isMenuOpen === true) {
      setMenu("translateX(0%)");
    } else {
      setMenu("translateX(-100%)");
    }
  }

  return (
    <div className='container'>
      <nav className='navigation'>
        <div className='navburger'>
          <IconContext.Provider
            value={{
              color: "white",
              size: "1.2em",
              className: "global-class-name",
            }}
          >
            <GiHamburgerMenu onClick={openMenu} />
          </IconContext.Provider>
        </div>
        <div className='brand'>
          <h2>Chubbini</h2>
        </div>
        <ul className='nav-links' style={{ transform: menu }}>
          <li>
            <a href='/a'>About</a>
          </li>
          <li>
            <a href='/a'>Product</a>
          </li>
          <li>
            <a href='/a'>Inquiries</a>
          </li>
          <li>
            <a href='/a'>FAQ</a>
          </li>
          <ProfileButtons />
        </ul>
      </nav>
    </div>
  );
}

export default App;

I understand the problem, it's just I'm not sure how to reach my conclusion...unless there's an easier way or I have to not useState...

Thanks for helping!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!