<commit_before>import { useEffect, useCallback, memo } from 'react';
import PropTypes from 'prop-types';
import { attempt } from 'lodash-es';
import useChart from '../UseChart';
import useModifiedProps from '../UseModifiedProps';


const Legend = memo(({ children = null, enabled = true, ...restProps}) => {

  const modifiedProps = useModifiedProps({ enabled, ...restProps});

  const { getChart, needsRedraw } = useChart();

  const updateLegend = useCallback(config => {
    const chart = getChart();
    chart.update({
      legend: config
    }, false);
    needsRedraw();
  }, [getChart, needsRedraw]);

  // componentDidMount && componentDidUpdate
  useEffect(() => {
    if (modifiedProps !== false) {

      updateLegend(modifiedProps);
    }
  },[modifiedProps, updateLegend]);

  useEffect(() => {
    // componentWillUnmount
    return () => attempt(updateLegend, { enabled: false });
  },[updateLegend]);

  return children;
})

Legend.propTypes = {
  enabled: PropTypes.bool
}
Legend.displayName = Legend;

export default Legend;<commit_msg>Fix Legend displayName<commit_after>import { useEffect, useCallback, memo } from 'react';
import PropTypes from 'prop-types';
import { attempt } from 'lodash-es';
import useChart from '../UseChart';
import useModifiedProps from '../UseModifiedProps';


const Legend = memo(({ children = null, enabled = true, ...restProps}) => {

  const modifiedProps = useModifiedProps({ enabled, ...restProps});

  const { getChart, needsRedraw } = useChart();

  const updateLegend = useCallback(config => {
    const chart = getChart();
    chart.update({
      legend: config
    }, false);
    needsRedraw();
  }, [getChart, needsRedraw]);

  // componentDidMount && componentDidUpdate
  useEffect(() => {
    if (modifiedProps !== false) {

      updateLegend(modifiedProps);
    }
  },[modifiedProps, updateLegend]);

  useEffect(() => {
    // componentWillUnmount
    return () => attempt(updateLegend, { enabled: false });
  },[updateLegend]);

  return children;
})

Legend.propTypes = {
  enabled: PropTypes.bool
}
Legend.displayName = 'Legend';

export default Legend;
{'fraction_non_alphanumeric': 0.14898632720414898, 'fraction_numerical': 0.0, 'mean_word_length': 3.9234338747099766, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2274663', 'n_tokens_mistral': 620, 'n_tokens_neox': 604, 'n_words': 157}