<commit_before>import normaliseUri from 'panels-normalise-uri';
import React, { Component, PropTypes } from 'react';
import toCSS from 'style-to-css';
import uniqueId from 'mini-unique-id';

export default class Teleport extends Component {
  constructor(props) {
    super(props);
    this.id = uniqueId();
  }

  render() {
    const { context, children, focus, loose, onClick, style, styleActive, styleHover, title, to, ...rest } = this.props;
    const { isActive, navigate, route } = this.context;
    const active = isActive(to, loose);
    const className = `Teleport-${this.id}`;
    const href = normaliseUri(`${route.context}${to}`);

    const inlineStyle = styleHover ? `.${className}:hover {${toCSS(styleHover)}}` : '';
    const finalStyle = active ? {
      ...style,
      ...styleActive
    } : style;

    function finalOnClick(event) {
      event.preventDefault();
      let preventNavigate = false;

      if (typeof onClick === 'function') {
        preventNavigate = onClick(event);
      }

      if (preventNavigate !== true) {
        navigate(to, focus, context);
      }
    }

    return (
      <a {...rest} className={className} href={href} onClick={finalOnClick} style={finalStyle} title={title}>
        {children}
        <style>
          {inlineStyle}
        </style>
      </a>
    );
  }
}
Teleport.contextTypes = {
  isActive: PropTypes.func.isRequired,
  navigate: PropTypes.func.isRequired,
  route: PropTypes.shape({
    app: PropTypes.string.isRequired,
    context: PropTypes.string.isRequired,
    path: PropTypes.string.isRequired
  }).isRequired
};
<commit_msg>fix: revert regression on context in teleport<commit_after>import normaliseUri from 'panels-normalise-uri';
import React, { Component, PropTypes } from 'react';
import toCSS from 'style-to-css';
import uniqueId from 'mini-unique-id';

// NOTE Don't destruct this.context.
export default class Teleport extends Component {
  constructor(props) {
    super(props);
    this.id = uniqueId();
  }

  render() {
    const { context, children, focus, loose, onClick, style, styleActive, styleHover, title, to, ...rest } = this.props;
    const active = this.context.isActive(to, loose);
    const className = `Teleport-${this.id}`;
    const href = normaliseUri(`${this.context.route.context}${to}`);

    const inlineStyle = styleHover ? `.${className}:hover {${toCSS(styleHover)}}` : '';
    const finalStyle = active ? {
      ...style,
      ...styleActive
    } : style;

    const finalOnClick = event => {
      event.preventDefault();
      let preventNavigate = false;

      if (typeof onClick === 'function') {
        preventNavigate = onClick(event);
      }

      if (preventNavigate !== true) {
        this.context.navigate(to, focus, context);
      }
    }

    return (
      <a {...rest} className={className} href={href} onClick={finalOnClick} style={finalStyle} title={title}>
        {children}
        <style>
          {inlineStyle}
        </style>
      </a>
    );
  }
}
Teleport.contextTypes = {
  isActive: PropTypes.func.isRequired,
  navigate: PropTypes.func.isRequired,
  route: PropTypes.shape({
    app: PropTypes.string.isRequired,
    context: PropTypes.string.isRequired,
    path: PropTypes.string.isRequired
  }).isRequired
};

{'fraction_non_alphanumeric': 0.14307551207581778, 'fraction_numerical': 0.0, 'mean_word_length': 3.0595533498759306, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3890930', 'n_tokens_mistral': 977, 'n_tokens_neox': 982, 'n_words': 232}