Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Redirect, Link } from 'react-router-dom';
  3. import style from './nav-button.css';
  4.  
  5. class NavButton extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = { redirect: false };
  9. }
  10.  
  11. click = () => {
  12. this.setState({redirect: true})
  13. }
  14.  
  15. render() {
  16. if (this.state.redirect) {
  17. return <Redirect to={this.props.nav} />
  18. }
  19.  
  20. return (
  21. <button className={style.NavButton} onClick={this.click}>
  22. {this.props.label}
  23. </button>
  24. );
  25. }
  26. }
  27.  
  28. export default NavButton;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement