<commit_before>import * as React from "react";
import { connect } from "react-redux";
import { IState } from "store/interfaces/State";
import { publicationRouteChanged } from "store/actions/Actions";
import { IPublicationContentPropsParams } from "components/PublicationContent//PublicationContentPresentaion";
import { withRouter } from "react-router";
import { IPublicationCurrentState } from "store/interfaces/State";
import { getCurrentPub } from "store/reducers/Reducer";

export interface ISyncParams {
    onRouteChange: (publication: IPublicationCurrentState) => {};
    params: IPublicationContentPropsParams;
}

export type Props = IPublicationCurrentState & ISyncParams;
export class RouteToState1 extends React.Component<Props, {}> {

    public shouldComponentUpdate(nextProps: Props): boolean {
        return this.routeChanged(this.props.params, nextProps.params)
            && this.routeEqualsToState(nextProps);
    }

    public componentDidUpdate(): void {
        const { params, onRouteChange } = this.props;
        onRouteChange(this.paramsToState(params));
    }

    public render(): JSX.Element {
        return <div />;
    }

    private paramsToState(params: IPublicationContentPropsParams): IPublicationCurrentState {
        return {
            publicationId: params.publicationId,
            pageId: /\d+/.test(params.pageIdOrPublicationTitle || "") ? params.pageIdOrPublicationTitle as string : ""
        };
    }
<commit_msg>KCWA-468 Fix state -> route<commit_after>import * as React from "react";
import { connect } from "react-redux";
import { IState } from "store/interfaces/State";
import { publicationRouteChanged } from "store/actions/Actions";
import { IPublicationContentPropsParams } from "components/PublicationContent//PublicationContentPresentaion";
import { withRouter } from "react-router";
import { IPublicationCurrentState } from "store/interfaces/State";
import { getCurrentPub } from "store/reducers/Reducer";

export interface ISyncParams {
    onRouteChange: (publication: IPublicationCurrentState) => {};
    params: IPublicationContentPropsParams;
}

export type Props = IPublicationCurrentState & ISyncParams;
export class RouteToState1 extends React.Component<Props, {}> {

    public shouldComponentUpdate(nextProps: Props): boolean {
        return this.routeChanged(this.props.params, nextProps.params)
            && !this.routeEqualsToState(nextProps);
    }

    public componentDidUpdate(): void {
        const { params, onRouteChange } = this.props;
        onRouteChange(this.paramsToState(params));
    }

    public render(): JSX.Element {
        return <div />;
    }

    private paramsToState(params: IPublicationContentPropsParams): IPublicationCurrentState {
        return {
            publicationId: params.publicationId,
            pageId: /\d+/.test(params.pageIdOrPublicationTitle || "") ? params.pageIdOrPublicationTitle as string : ""
        };
    }

{'fraction_non_alphanumeric': 0.10608636518191092, 'fraction_numerical': 0.0017001020061203672, 'mean_word_length': 4.06368330464716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '7578660', 'n_tokens_mistral': 810, 'n_tokens_neox': 794, 'n_words': 171}