negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.05k stars 586 forks source link

pushRotate not working #418

Closed laazaz closed 3 years ago

laazaz commented 3 years ago

I did the same example as described in here, most of them work except the "pushRotate" which generates just a "slide" menu

https://www.digitalocean.com/community/tutorials/react-react-burger-menu-sidebar

`import` { pushRotate as Menu } from 'react-burger-menu';
negomi commented 3 years ago

Hey @laazaz,

Are you getting any console errors when you open and close the menu?

My guess is that the outer container and page wrap IDs are missing or incorrect:

function App() {
  return (
    <div className="App" id="outer-container">
      <Sidebar pageWrapId={'page-wrap'} outerContainerId={'outer-container'} />
      <div id="page-wrap">
        <h1>Cool Restaurant</h1>
        <h2>Check out our offerings in the sidebar!</h2>
      </div>
    </div>
  );
}

If the pageWrapId and outerContainerId props don't match the IDs of these elements, you will just see a slide effect for a lot of the menus.

laazaz commented 3 years ago

@negomi thanks for the answer I have exactly the same code

App.js:

import React from 'react';
import './App.css';
import Sidebar from './Sidebar';

function App() {
  return (
    <div className="App" id="outer-container">
      <Sidebar pageWrapId={'page-wrap'} outerContainerId={'outer-container'} />
      <div id="page-wrap">
        <h1>Cool Restaurant</h1>
        <h2>Check out our offerings in the sidebar!</h2>
      </div>
    </div>
  );
}

export default App;

Sidebar.js:

import React from 'react';
import './Sidebar.css';
import { pushRotate as Menu } from 'react-burger-menu';

export default props => {
  return (
    <Menu>
      <a className="menu-item" href="/">
        Home
      </a>
      <a className="menu-item" href="/salads">
        Salads
      </a>
      <a className="menu-item" href="/pizzas">
        Pizzas
      </a>
      <a className="menu-item" href="/desserts">
        Desserts
      </a>
    </Menu>
  );
};

The version I've installed: npm install react-burger-menu@2.7.1

The warning it gives (before opening the menu, and nothing happens after):

image

Tried on Firefox, Chrome (last versions)

Thank you

EDIT: fixed the warning by simply writing export default function Sss() { on the 5th line, but still doesn't work of course.

negomi commented 3 years ago

Ah, the problem is you're adding those props to the Sidebar but not passing them through to the Menu.

So you would need to either name them individually:

<Menu pageWrapId={props.pageWrapId} outerContainerId={props.outerContainerId}>

Or pass all props through:

<Menu {...props}>

And the linter warning is unrelated, as you discovered 🙂