Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
(MUI v5) TypeError no capturado: no se pueden leer las propiedades de undefined (leyendo 'focus')

Estoy usando un campo de textfield para enviar datos a la base de datos. Quiero hacer que el campo de texto se enfoque cuando el componente se useRef textfield Sin embargo, seguí recibiendo el error: Uncaught TypeError: Cannot read properties of undefined (reading 'focus') .

Mi código:

 const StyledTooltip = styled(Tooltip)(({ theme }) => ({ ... })); const CreateBox = styled(Box)(({ theme }) => ({ ... })); const LoginTextField = styled(TextField)({ ... }); function Create () { const inputRef = useRef(); const [openCreate, setOpenCreate] = useState(false); const toggleCreateWindow = () => { setOpenCreate(!openCreate); }; useEffect(() => { inputRef.current.focus(); }, []) return ( <> <Modal aria-labelledby='create' aria-describedby='create' open={openCreate} onClose={toggleCreateWindow} closeAfterTransition BackdropComponent={Backdrop} BackdropProps={{ timeout: 500 }}> <Fade in={openCreate}> <CreateBox> <LoginTextField label='Content' variant='outlined' placeholder="Writing something about Japan......" inputRef={inputRef} multiline rows={12} maxRows={14} InputLabelProps={{ style: { color: 'white' } }} inputProps={{ style: { color: "white" } }} /> </CreateBox> </Fade> </Modal> <StyledTooltip title='Create'> <Fab aria-label='create' onClick={toggleCreateWindow}> <EditIcon /> </Fab> </StyledTooltip> </> ); }; export default Create;

¿Es un problema único para el campo de textfield ? Porque funciona bien con el campo de texto html textfield Alguien tiene una idea de lo que está mal con mi código? ¡Muy apreciado!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!