0
How to pass information between components in React as props or status.
In this situation I have a button and a menu. The menu should open every time the button is clicked.
Knob
import React, { Component } from 'react';
import './Navbar.css';
class Navbar
extends Component {
state = { }
render() {
return (
<nav>
<button className="MenuSlide">
<span></span>
<span></span>
<span></span>
</button>
</nav>
);
}
}
export default Navbar;
Menu
import React, { Component } from 'react';
class Menu extends Component {
render() {
return (
<aside>
{this.props.children}
</aside>
);
}
}
export default Menu;
Page where the components are.
import React, { Component } from 'react';
/* Components */
import Navbar from '../../component/top/Navbar';
import Menu from '../../component/sideBar/Menu';
import Main from "../../component/sideCenter/Main";
class Dashboard extends Component {
render() {
return (
<div className="App" data>
<Navbar />
<Menu />
</div>
);
}
}
export default Dashboard;