<commit_before>﻿import LinkUtility from './LinkUtility';
import withStateNavigator from './withStateNavigator';
import { NavigationBackLinkProps } from './Props';
import * as React from 'react';
type NavigationBackLinkState = { link?: string, crumb?: number };

class NavigationBackLink extends React.Component<NavigationBackLinkProps, NavigationBackLinkState> {
    constructor(props, context) {
        super(props, context);
        this.state = { crumb: props.stateNavigator.stateContext.crumbs.length };
    }

    static getDerivedStateFromProps(props, { crumb }) {
        var { acrossCrumbs, distance, stateNavigator } = props;
        var { crumbs, state } = stateNavigator.stateContext;
        if (!acrossCrumbs && crumb !== crumbs.length)
            return null;
        try {
            var link = stateNavigator.getNavigationBackLink(distance);
        } catch {}
        return { link };
    }

    render() {
        var props: any = {};
        for(var key in this.props) {
            if (LinkUtility.isValidAttribute(key))
                props[key] = this.props[key];
        }
        props.href = this.state.link && this.props.stateNavigator.historyManager.getHref(this.state.link);
        props.onClick = LinkUtility.getOnClick(this.props.stateNavigator, this.props, this.state.link);
        return <a {...props}>{this.props.children}</a>;
    }
};
export default withStateNavigator(NavigationBackLink);
<commit_msg>Removed legacy context from constructor<commit_after>﻿import LinkUtility from './LinkUtility';
import withStateNavigator from './withStateNavigator';
import { NavigationBackLinkProps } from './Props';
import * as React from 'react';
type NavigationBackLinkState = { link?: string, crumb?: number };

class NavigationBackLink extends React.Component<NavigationBackLinkProps, NavigationBackLinkState> {
    constructor(props) {
        super(props);
        this.state = { crumb: props.stateNavigator.stateContext.crumbs.length };
    }

    static getDerivedStateFromProps(props, { crumb }) {
        var { acrossCrumbs, distance, stateNavigator } = props;
        var { crumbs, state } = stateNavigator.stateContext;
        if (!acrossCrumbs && crumb !== crumbs.length)
            return null;
        try {
            var link = stateNavigator.getNavigationBackLink(distance);
        } catch {}
        return { link };
    }

    render() {
        var props: any = {};
        for(var key in this.props) {
            if (LinkUtility.isValidAttribute(key))
                props[key] = this.props[key];
        }
        props.href = this.state.link && this.props.stateNavigator.historyManager.getHref(this.state.link);
        props.onClick = LinkUtility.getOnClick(this.props.stateNavigator, this.props, this.state.link);
        return <a {...props}>{this.props.children}</a>;
    }
};
export default withStateNavigator(NavigationBackLink);

{'fraction_non_alphanumeric': 0.1188666205943331, 'fraction_numerical': 0.0, 'mean_word_length': 3.0376569037656904, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2481855', 'n_tokens_mistral': 810, 'n_tokens_neox': 805, 'n_words': 172}