import * as React from 'react';
import { ConfigContextType, ConfigType, InitConfig } from './ConfigContext';

export const useConfig = (): ConfigContextType => {
  const [config, _setConfig] = React.useState<ConfigType>(InitConfig);

  const setConfig = React.useCallback(
    (currentConfig: ConfigType): void => {
      _setConfig(currentConfig);
    },
    []
  );

  return {
    config,
    setConfig,
  };
};
