Topic: The sidenav example doesn\'t work
Bhagya pro asked 6 years ago
import React, { Component } from 'react'; import { BrowserRouter as Router } from 'react-router-dom'; import SideNavPage from './components/SideNavPage' class App extends Component { render() { return ( <div> <SideNavPage/> </div> ); } } export default App;SideNavPage.js is this, which is same as your sample code except without logo urls.
import React from 'react'; import { BrowserRouter as Router } from 'react-router-dom'; import { Fa, SideNavItem, SideNavCat, SideNavNav, SideNav, SideNavLink, Container, Row } from 'mdbreact'; class SideNavPage extends React.Component { constructor(props) { super(props); this.state ={ isLeftOpen: false, isRightOpen: false }; } // Slide out buttons event handlers handleToggleClickA = () => { this.setState({ isLeftOpen: !this.state.isLeftOpen }) } handleToggleClickB = () => { this.setState({ isRightOpen: !this.state.isRightOpen }) } render() { // Because the toggling buttons are nearly identical, we create a function to render them: const createButton = (onClick, side) => { return <div style={{width: "50%", textAlign: "center"}}> <a href="#!" onClick={onClick} key={'toggleThe'+side+'SideNav'}><Fa icon="bars" size="5x"></Fa></a> </div> } return ( <Router> <div> <Container> {/* the buttons toggling visibility of SideNavs: */} <Row style={{height: "80vh", alignItems: "center"}} > {createButton(this.handleToggleClickA, "Left")} {createButton(this.handleToggleClickB, "Right")} </Row> {/* the left SideNav: */} <SideNav hidden triggerOpening={this.state.isLeftOpen} breakWidth={1300} className="deep-purple darken-4"> <li> <ul className="social"> <li><a href="#!"><Fa icon="facebook"></Fa></a></li> <li><a href="#!"><Fa icon="pinterest"></Fa></a></li> <li><a href="#!"><Fa icon="google-plus"></Fa></a></li> <li><a href="#!"><Fa icon="twitter"></Fa></a></li> </ul> </li> <SideNavNav> <SideNavCat id="submit-blog-cat" name="Submit blog" icon="chevron-right"> <SideNavLink>Submit listing</SideNavLink> <SideNavLink>Registration form</SideNavLink> </SideNavCat> <SideNavCat id="instruction-cat" name="Instruction" icon="hand-pointer-o" href="#"> <SideNavLink>For bloggers</SideNavLink> <SideNavLink>For authors</SideNavLink> </SideNavCat> <SideNavCat id="about-cat" name="About" icon="eye"> <SideNavLink>Instruction</SideNavLink> <SideNavLink>Monthly meetings</SideNavLink> </SideNavCat> <SideNavCat id="contact-me-cat" name="Contact me" icon="envelope-o"> <SideNavLink>FAQ</SideNavLink> <SideNavLink>Write a message</SideNavLink> </SideNavCat> </SideNavNav> </SideNav> {/* the right SideNav: */} <SideNav hidden triggerOpening={this.state.isRightOpen} className="side-nav-light" right breakWidth={1300}> <li> <ul className="social"> <li><a href="#!"><Fa icon="facebook"></Fa></a></li> <li><a href="#!"><Fa icon="pinterest"></Fa></a></li> <li><a href="#!"><Fa icon="google-plus"></Fa></a></li> <li><a href="#!"><Fa icon="twitter"></Fa></a></li> </ul> </li> <SideNavNav> <SideNavCat id="submit-blog-cat" name="Submit blog" icon="chevron-right" > <SideNavLink className="active">Submit listing</SideNavLink> <SideNavLink>Registration form</SideNavLink> </SideNavCat> <SideNavCat id="instruction-cat" name="Instruction" icon="hand-pointer-o"> <SideNavLink>For bloggers</SideNavLink> <SideNavLink>For authors</SideNavLink> </SideNavCat> <SideNavCat id="about-cat" name="About" icon="eye"> <SideNavLink>Instruction</SideNavLink> <SideNavLink>Monthly meetings</SideNavLink> </SideNavCat> <SideNavCat id="contact-me-cat" name="Contact me" icon="envelope-o"> <SideNavLink>FAQ</SideNavLink> <SideNavLink>Write a message</SideNavLink> </SideNavCat> </SideNavNav> </SideNav> </Container> </div> </Router> ); } } export default SideNavPage;
Anna Morawska staff answered 6 years ago
yujanrichie free answered 6 years ago
Anna Morawska staff answered 6 years ago
Anna Morawska staff answered 6 years ago
Bhagya pro commented 6 years ago
Thanks Anna, it works. Can you provide the source of this SideNav implementation? https://mdbootstrap.com/previews/docs/latest/html/skins/grey-skin.htmlFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: 4.7.1
- Device: Desktop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No
Anna Morawska staff commented 6 years ago
Hello, thank you for sharing this :) Well, but it's interesting, I've just copy-paste our snippet and it looks like it works fine for me. Best, AniaBhagya pro commented 6 years ago
Hi Anna, Thanks for the response. Did you use create-react-app to generate your project? I tried on different browsers, but still the same result. Is it possible for you to share your code? ThanksAnna Morawska staff commented 6 years ago
Hi, yes, actually my setup is the same as in our zip package ( basically CRA boilerplate ). The code is the same as in our snippet. Maybe something went wrong during installation? Did you follow our "5 min Quick Start" tutorial? Best, AniaBhagya pro commented 6 years ago
Yes, my all other components are fine. I tried to add sidenav but failed.Bhagya pro commented 6 years ago
Also, SideNav is a Pro component. It does not in your zip package.Anna Morawska staff commented 6 years ago
What version are you using? 4.7.1? If so, please update it to v. 4.8.0, it should fix the problem. There were some syntax changes since then.Bhagya pro commented 6 years ago
I'm using pro version like this, "mdbreact": "git+https://oauth2: