I understand that we cannot use hooks outside a component, but was looking for a workaround of using function from context hook outside a react component to show toast (using a separate utility function).
Saw usage of event emitters for achieving this but wanted to explore some another workaround if its there. Creating A React Component That Can Be Shown With A Function Call (like react-toastify
export const useToast = () => React.useContext(ToastContext);
and
const { add } = useToast();
Basically, want to use this function from context outside a component.