M
M
MRcracker2021-10-06 12:59:19
React
MRcracker, 2021-10-06 12:59:19

How to do a class switch?

I have two components.

The first component contains the code for displaying the button and the hook. The second component contains a menu that should appear when you click on the button from the first component, but I did something wrong. Tell me how to pass parameters from one component to another correctly?

const [menuOpened, setMenuOpened] = useState("false");

  const handleToggle = () => {
    setMenuOpened(!menuOpened);
  };

  return (
    <div
                className={[styles.hamburger, styles.topLineHamburger].join(
                  " "
                )}
                onClick={handleToggle}
              >
                <span className={styles.hamburgerItem}></span>
              </div>{" "} )}

export default function Navbar(props) {
console.log(props);
  return (
    <nav className={styles.navbar}>
      <div className="container">
        <div className={props ? "d-none" : " "}>
)}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Makarov, 2021-10-06
@MRcracker

You have everything mixed up and styles from css and styles from modules, in general, everything is mixed. Here I threw it as I understood what you need https://codesandbox.io/s/heuristic-currying-jm0ur?...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question