The code powering m.abunchtell.com https://m.abunchtell.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

37 righe
773 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. class Permalink extends React.PureComponent {
  4. static contextTypes = {
  5. router: PropTypes.object,
  6. };
  7. static propTypes = {
  8. className: PropTypes.string,
  9. href: PropTypes.string.isRequired,
  10. to: PropTypes.string.isRequired,
  11. children: PropTypes.node,
  12. };
  13. handleClick = (e) => {
  14. if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
  15. e.preventDefault();
  16. this.context.router.history.push(this.props.to);
  17. }
  18. }
  19. render () {
  20. const { href, children, className, ...other } = this.props;
  21. return (
  22. <a href={href} onClick={this.handleClick} {...other} className={'permalink ' + className}>
  23. {children}
  24. </a>
  25. );
  26. }
  27. }
  28. export default Permalink;