Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import React from 'react'
import { LinkProps } from './typings'
import {
  renderLink as defaultRenderLink,
  renderChildren as defaultRenderChildren,
} from './renderProps'

class Link extends React.PureComponent<LinkProps> {
  static defaultProps = {
    // className: ''
    text: 'Link',
    // http://uxui.skavaone.com
    to: '',
    target: '_blank',
    renderLink: defaultRenderLink,
    renderChildren: defaultRenderChildren,
  }
  render() {
    let {
      text,
      to,
      href,
      link,
      url,
      onClick,
      urlBase,
      target,
      nofollow,
      shouldNotFollow,
      ...remainingProps
    } = this.props

    to = to || href || url || link || onClick
    nofollow = nofollow || shouldNotFollow

    // packing the required props into attr
    const attr = {
      text,
      target,
      urlBase,
      ...remainingProps,
    }

    // setting nofollow
    if (nofollow === true) {
      attr.rel = 'nofollow'
    }

    // assigning href
    attr.href = to

    const children = this.props.renderChildren(attr)
    const view = this.props.renderLink({ ...attr, children })
    return view
  }
}

export { Link }
export default Link