<commit_before>import React, { Component, PropTypes } from 'react';

export default (mapStateToProps, mapActionsToProps) => WrappedComponent =>{
  return class extends Component {
    static contextTypes = {
      serverRouter: PropTypes.object,
      serverState: PropTypes.object,
      reactRouterServerFetchStateParentId: PropTypes.string
    };

    static childContextTypes = {
      reactRouterServerFetchStateParentId: PropTypes.string
    };

    getChildContext() {
      return {
        reactRouterServerFetchStateParentId: this.idx
      };
    }

    constructor() {
      super();
      this.state = {};
    }

    get asyncRenderer() {
      return typeof this.context.serverRouter === 'object' && this.context.serverRouter.asyncRenderer ?
        this.context.serverRouter.asyncRenderer : null;
    }

    componentWillMount() {
      if (this.asyncRenderer) {
        this.idx = this.asyncRenderer.getAsyncMountIdx(this.context.reactRouterServerFetchStateParentId);
        if (!this.asyncRenderer.hasAsyncMountResult(this.idx)) {
          this.asyncRenderer.awaitForAsyncMount++;
        } else {
          this.setState({ ...this.asyncRenderer.getAsyncMountResult(this.idx) });
        }
      } else if (this.context.serverState) {
        this.idx = this.context.serverState.getAsyncMountIdx(this.context.reactRouterServerFetchStateParentId);
        const state = this.context.serverState.getState(this.idx);
        if (state) {
          this.setState({ ...state });
        }
      }
    }

    actions = () => ({
      done: this.handleDone
    });

    handleDone = data => {
      if (this.asyncRenderer) {
        if (!this.asyncRenderer.hasAsyncMountResult(this.idx)) {
          this.asyncRenderer.storeAsyncMountResult(this.idx, data);
          this.asyncRenderer.awaitForAsyncMount--;
          this.asyncRenderer.handleAsyncComponentMounted();
        }
      } else {
        this.setState({ ...data });
      }
    };

    render() {
      let nextProps = { ...this.props };
      if (mapStateToProps) nextProps = { ...nextProps, ...mapStateToProps(this.state) };
      if (mapActionsToProps) nextProps = { ...nextProps, ...mapActionsToProps(this.actions()) };
      return <WrappedComponent {...nextProps}/>;
    }
  };
};
<commit_msg>simpke fix for warning about setState...see issus #6<commit_after>import React, { Component, PropTypes } from 'react';

export default (mapStateToProps, mapActionsToProps) => WrappedComponent =>{
  return class extends Component {
    static contextTypes = {
      serverRouter: PropTypes.object,
      serverState: PropTypes.object,
      reactRouterServerFetchStateParentId: PropTypes.string
    };

    static childContextTypes = {
      reactRouterServerFetchStateParentId: PropTypes.string
    };

    getChildContext() {
      return {
        reactRouterServerFetchStateParentId: this.idx
      };
    }

    constructor() {
      super();
      this.state = {};
    }

    componentDidMount() {
      this._isMounted = true
    }

    componentWillUnmount() {
      this._isMounted = false
    }

    get asyncRenderer() {
      return typeof this.context.serverRouter === 'object' && this.context.serverRouter.asyncRenderer ?
        this.context.serverRouter.asyncRenderer : null;
    }

    componentWillMount() {
      if (this.asyncRenderer) {
        this.idx = this.asyncRenderer.getAsyncMountIdx(this.context.reactRouterServerFetchStateParentId);
        if (!this.asyncRenderer.hasAsyncMountResult(this.idx)) {
          this.asyncRenderer.awaitForAsyncMount++;
        } else {
          this.setState({ ...this.asyncRenderer.getAsyncMountResult(this.idx) });
        }
      } else if (this.context.serverState) {
        this.idx = this.context.serverState.getAsyncMountIdx(this.context.reactRouterServerFetchStateParentId);
        const state = this.context.serverState.getState(this.idx);
        if (state) {
          this.setState({ ...state });
        }
      }
    }

    actions = () => ({
      done: this.handleDone
    });

    handleDone = data => {
      if (this.asyncRenderer) {
        if (!this.asyncRenderer.hasAsyncMountResult(this.idx)) {
          this.asyncRenderer.storeAsyncMountResult(this.idx, data);
          this.asyncRenderer.awaitForAsyncMount--;
          this.asyncRenderer.handleAsyncComponentMounted();
        }
      } else if (this._isMounted) {
        this.setState({ ...data });
      }
    };

    render() {
      let nextProps = { ...this.props };
      if (mapStateToProps) nextProps = { ...nextProps, ...mapStateToProps(this.state) };
      if (mapActionsToProps) nextProps = { ...nextProps, ...mapActionsToProps(this.actions()) };
      return <WrappedComponent {...nextProps}/>;
    }
  };
};

{'fraction_non_alphanumeric': 0.12473617560151963, 'fraction_numerical': 0.00021105951878429716, 'mean_word_length': 2.612042682926829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '7274622', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1325, 'n_words': 213}