<commit_before>// @flow strict-local

import React, { type Node } from 'react';
import { jss as jssNs } from 'react-jss/lib/ns';
import { createTheming } from 'react-jss';
import { getDynamicStyles } from 'jss';
import SheetsManager from 'jss/lib/SheetsManager';
import Jss from 'jss/lib/Jss';
import contextTypes from 'react-jss/lib/contextTypes';
import StyleSheet from 'jss/lib/StyleSheet';

import { mergeClassObjects } from './utils';

type Theme = {};
type StaticStyles = { [key: string]: {} };
type ThemedStyles = (theme: Theme) => StaticStyles;
type Styles = StaticStyles | ThemedStyles;
type Context = {};
type Classes = { [key: string]: string };
type State = {
  classes: Classes,
  theme: Theme,
};
type Props = {
  children: ({ classes: Classes }) => Node,
  data?: {},
};

let indexCounter = -100000; // eslint-disable-line fp/no-let
const { themeListener } = createTheming();
const DynamicStylesMap = new Map();
const noTheme = {};

export default function createSheet(name: string, styles: Styles) {
  const isThemingEnabled = typeof styles === 'function';
  const manager = new SheetsManager();

  indexCounter += 1;

  class Sheet extends React.Component<Props, State> {
    static defaultProps = { data: null };

    static contextTypes = Object.assign(
      {},
      contextTypes,
      isThemingEnabled ? themeListener.contextTypes : {},
    );

    static index = indexCounter;

    constructor(props: Props, context: Context) {
      super(props, context);

      const initialTheme = isThemingEnabled ? themeListener.initial(context) : noTheme;

      this.state = this.createState(initialTheme);
      this.jss = context[jssNs];

      if (isThemingEnabled) {
        this.unsubscribeId = themeListener.subscribe(context, this.handleThemeUpdate);
      }
    }

    componentDidUpdate(prevProps: Props) {
      if (this.dynamicSheet !== null && this.props.data !== prevProps.data) {
        this.dynamicSheet.update(this.props.data);
      }
    }<commit_msg>Fixed order of defining jss in the Sheet component<commit_after>// @flow strict-local

import React, { type Node } from 'react';
import { jss as jssNs } from 'react-jss/lib/ns';
import { createTheming } from 'react-jss';
import { getDynamicStyles } from 'jss';
import SheetsManager from 'jss/lib/SheetsManager';
import Jss from 'jss/lib/Jss';
import contextTypes from 'react-jss/lib/contextTypes';
import StyleSheet from 'jss/lib/StyleSheet';

import { mergeClassObjects } from './utils';

type Theme = {};
type StaticStyles = { [key: string]: {} };
type ThemedStyles = (theme: Theme) => StaticStyles;
type Styles = StaticStyles | ThemedStyles;
type Context = {};
type Classes = { [key: string]: string };
type State = {
  classes: Classes,
  theme: Theme,
};
type Props = {
  children: ({ classes: Classes }) => Node,
  data?: {},
};

let indexCounter = -100000; // eslint-disable-line fp/no-let
const { themeListener } = createTheming();
const DynamicStylesMap = new Map();
const noTheme = {};

export default function createSheet(name: string, styles: Styles) {
  const isThemingEnabled = typeof styles === 'function';
  const manager = new SheetsManager();

  indexCounter += 1;

  class Sheet extends React.Component<Props, State> {
    static defaultProps = { data: null };

    static contextTypes = Object.assign(
      {},
      contextTypes,
      isThemingEnabled ? themeListener.contextTypes : {},
    );

    static index = indexCounter;

    constructor(props: Props, context: Context) {
      super(props, context);

      this.jss = context[jssNs];

      const initialTheme = isThemingEnabled ? themeListener.initial(context) : noTheme;

      this.state = this.createState(initialTheme);

      if (isThemingEnabled) {
        this.unsubscribeId = themeListener.subscribe(context, this.handleThemeUpdate);
      }
    }

    componentDidUpdate(prevProps: Props) {
      if (this.dynamicSheet !== null && this.props.data !== prevProps.data) {
        this.dynamicSheet.update(this.props.data);
      }
    }
{'fraction_non_alphanumeric': 0.13017456359102245, 'fraction_numerical': 0.003491271820448878, 'mean_word_length': 3.7411347517730498, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7558771', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1182, 'n_words': 320}