All files / src/components Link.js

100% Statements 2/2
100% Branches 4/4
100% Functions 1/1
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                      4x                         9x            
/**
 * @copyright   2016, Miles Johnson
 * @license     https://opensource.org/licenses/MIT
 * @flow
 */
 
import React, { PropTypes } from 'react';
 
import type { LinkProps } from '../types';
 
export default function Link({ children, href, onClick, newWindow }: LinkProps) {
  return (
    <a
      href={href}
      className="interweave__link"
      target={newWindow ? '_blank' : null}
      onClick={onClick || null}
      rel="noopener noreferrer"
    >
      {children}
    </a>
  );
}
 
Link.propTypes = {
  children: PropTypes.node.isRequired,
  href: PropTypes.string.isRequired,
  onClick: PropTypes.func,
  newWindow: PropTypes.bool,
};