I'm not sure if this is the best way to do something, but I want to pass one variable of the class name to another responsive component.
This button starts the onClick animation by simply adding one class name to several elements. Also did I create var = overlay this.state.cliked? 'open': '' to start the overlay, if I have an overlay html on the same component, it works fine, but I have to make the small components as I can.
var React = require('react'); var OverlayView = require('./OverlayView.jsx'); var StatusBarButtonView = React.createClass({ getInitialState: function() { return {cliked: false}; }, handleClick: function(event) { this.setState({cliked: !this.state.cliked}); }, render: function() { var fondo = this.state.cliked ? 'active' : ''; var overlay = this.state.cliked ? 'open' : ''; return ( <div> <div className={"statusbar-button-container " + (fondo)} onClick={this.handleClick}> <img src="images/navbar-element-icon-cross.png" className={"rotate " + (fondo)}/> </div> </div> <OverlayView className={overlay} /> ); } }); module.exports = StatusBarButtonView;
As you can see, this is the overlay component that I want to pass to this component, but I'm not sure if it can just be alone and start when this processes the click. Im a little lost with the reaction, not much information on the internet and im new with that.
This is the Overlay component:
var React = require('react'); var OverlayView = React.createClass({ return ( <div className={"overlay overlay-slidedown " + this.props.class}> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Work</a></li> <li><a href="#">Clients</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </div> ); } }); module.exports = OverlayView;
I'm not sure how to do this, I'm looking for examples on the Internet, but nothing is clear to me :(
source share