<commit_before>// @flow

import * as React from 'react';
import { Helmet } from 'react-helmet';
import config from 'app/config';
import { type ComponentType, createElement } from 'react';

/**
 * A higher order component that wraps the given component in
 * LoadingIndicator while `props[loadingProp]` is being fetched.
 */

type PropertyGenerator = (
  props: Object,
  config?: Object
) => Array<{
  property?: string,
  content?: string,
  element?: string,
  children?: string,
  rel?: string,
  href?: string
}>;

export default function helmet<T>(propertyGenerator: PropertyGenerator) {
  return (Component: ComponentType<T>) => ({
    PropertyGenerator,
    ...props
  }: T & {
    propertyGenerator: PropertyGenerator
  }) => [
    <Helmet key="helmet">
      {propertyGenerator(props, config).map(
        ({ element, children, ...props }, index) =>
          createElement(element || 'meta', { key: index, ...props }, children)
      )}
    </Helmet>,
    <Component key="component" {...props} /><commit_msg>Add null check to property generator<commit_after>// @flow

import * as React from 'react';
import { Helmet } from 'react-helmet';
import config from 'app/config';
import { type ComponentType, createElement } from 'react';

/**
 * A higher order component that wraps the given component in
 * LoadingIndicator while `props[loadingProp]` is being fetched.
 */

type PropertyGenerator = (
  props: Object,
  config?: Object
) => Array<{
  property?: string,
  content?: string,
  element?: string,
  children?: string,
  rel?: string,
  href?: string
}>;

export default function helmet<T>(propertyGenerator: ?PropertyGenerator) {
  return (Component: ComponentType<T>) => ({
    PropertyGenerator,
    ...props
  }: T & {
    propertyGenerator: PropertyGenerator
  }) => [
    <Helmet key="helmet">
      {!!propertyGenerator &&
        propertyGenerator(props, config).map(
          ({ element, children, ...props }, index) =>
            createElement(element || 'meta', { key: index, ...props }, children)
        )}
    </Helmet>,
    <Component key="component" {...props} />
{'fraction_non_alphanumeric': 0.14830710538865044, 'fraction_numerical': 0.0, 'mean_word_length': 3.5021459227467813, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '307981', 'n_tokens_mistral': 593, 'n_tokens_neox': 583, 'n_words': 180}