import React, { useCallback, useEffect, useRef, useState } from 'react'; import { CircleLoader } from 'react-spinners'; import { useCTA } from '../hooks/cta'; import * as Styled from './identify.styles'; export type Props = { connecting: boolean; onIdentify: (name: string) => void; setInteracted: (interacted: boolean) => void; }; export const LoadingWrapper: React.FC = () => ( ); export const Identify: React.FC = ({ connecting, onIdentify, setInteracted }) => { const [name, setName] = useState(''); const onChange = useCallback( (event: React.ChangeEvent) => setName(event.target.value), [], ); const onConnect = useCallback(() => { onIdentify(name); setInteracted(true); }, [name, onIdentify, setInteracted]); const input = useRef(null); useEffect(() => { setImmediate(() => { input.current?.focus(); }); }, []); const inputOnKeydown = useCallback( (event: React.KeyboardEvent) => { if (event.key === 'Enter') { onConnect(); } }, [onConnect], ); const buttonHandlers = useCTA(onConnect); if (connecting) { return ; } return ( go-music-player Set client name: ); };