import { useContext } from 'react';
import { WidgetContext } from 'providers/WidgetProvider/WidgetContext';

export const useWidget = (props?: WidgetProvider.Context) => {
	const context = useContext(WidgetContext);

	if (context === undefined) {
		throw new Error(
			'useWidgetState must be used within a WidgetStateProvider!'
		);
	}
	return context;
};
