The code powering m.abunchtell.com https://m.abunchtell.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

36 řádky
694 B

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