<commit_before>import * as React from 'react';

import { Store, StoreEventType } from './store';

export interface IUseStoreOptions<StoreState, MappedState> {
  eventType?: StoreEventType | StoreEventType[];
  mapState?: (storeState: StoreState) => MappedState;
}

export function useStore<StoreState = {}, MappedState = StoreState>(
  store: Store<StoreState>,
  options: IUseStoreOptions<StoreState, MappedState> = {},
): MappedState {
  const mapState = React.useCallback(
    (stateStore: StoreState): MappedState => (options.mapState ? options.mapState(stateStore) : (stateStore as any)),
    [options.mapState],
  );
  const [state, setState] = React.useState(mapState(store.state));

  React.useEffect(() => {
    const storeEvent = store.on(options.eventType || StoreEventType.Update, storeState => {
      setState(mapState(storeState));
    });

    return () => {
      storeEvent.remove();
    };
  }, []);

  return state;
}<commit_msg>Update use_store.ts<commit_after>import * as React from 'react';

import { Store, StoreEventType } from './store';

export interface IUseStoreOptions<StoreState, MappedState> {
  eventType?: StoreEventType | StoreEventType[];
  mapState?: (storeState: StoreState) => MappedState;
  deps?: any[];
}

export function useStore<StoreState = {}, MappedState = StoreState>(
  store: Store<StoreState>,
  options: IUseStoreOptions<StoreState, MappedState> = {},
): MappedState {
  const deps = option.deps || []; 
  const mapState = React.useCallback(
    (stateStore: StoreState): MappedState => (options.mapState ? options.mapState(stateStore) : (stateStore as any)),
    deps,
  );
  const [state, setState] = React.useState(mapState(store.state));

  React.useEffect(() => {
    const storeEvent = store.on(options.eventType || StoreEventType.All, storeState => {
      setState(mapState(storeState));
    });

    return () => {
      storeEvent.remove();
    };
  }, []);

  return state;
}
{'fraction_non_alphanumeric': 0.14860681114551083, 'fraction_numerical': 0.0, 'mean_word_length': 4.54, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '1408130', 'n_tokens_mistral': 597, 'n_tokens_neox': 593, 'n_words': 124}