import { useContext, useState } from 'react';
import { formPageContext, widgetsFormContext } from '@wix/bex-core/react';

export const useWidgetForm = () => {
  const formPageState = useContext(formPageContext);
  const widgetsFormState = useContext(widgetsFormContext);

  const [state] = useState(() => formPageState ?? widgetsFormState);

  return state;
};
