import { useState } from 'react' ; import useAttempt from 'shared/hooks/useAttemptNext' ; import useTeleport from 'teleport/useTeleport' ; import { Feature } from 'teleport/types' ; export default function useMain ( features ) { const ctx = useTeleport ( ) ; const { attempt , run } = useAttempt ( 'processing' ) ; useState ( ( ) => run ( ( ) => ctx . init ( ) . then ( ( ) => features . forEach ( f => f . register ( ctx ) ) ) ) ) ; return { ctx , status : attempt . status , statusText : attempt . statusText , } ; } export type State = ReturnType < typeof useMain > ;