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

503
Views
¿Por qué en el campo de entrada de reacción pierde el foco?

Lo busqué pero nada parece estar funcionando para mí. Además, como novato, no pude implementar una solución dada basada en los teoremas de reacción.

Tengo un campo de entrada dentro de un componente con estilo y cuando trato de ingresar el valor en el campo después de presionar una tecla, la entrada pierde el foco.

 import React, { useState } from 'react'; import styled from 'styled-components'; import Button from '../../UI/Button/Button'; import './CourseInput.css'; const CourseInput = props => { const [enteredValue, setEnteredValue] = useState(''); const [isValid, setIsValid] = useState(true); const goalInputChangeHandler = event => { if (event.target.value.length > 0) { setIsValid(true); } setEnteredValue(event.target.value); }; const formSubmitHandler = event => { event.preventDefault(); if (enteredValue.trim().length === 0) { setIsValid(false); return; } props.onAddGoal(enteredValue); }; const FormControl = styled.div` margin: 0.5rem 0; & label { font-weight: bold; display: block; margin-bottom: 0.5rem; color: ${porps => props.invalid ? 'red ' : 'black'} } & input { display: block; width: 100%; border: 1px solid ${props => (props.invalid ? 'red' : '#ccc')}; background:${porps => props.invalid ? '#ffd7d7' : 'transparent'} font: inherit; line-height: 1.5rem; padding: 0 0.25rem; } & input:focus { outline: none; background: #fad0ec; border-color: #8b005d; } `; return ( <form onSubmit={formSubmitHandler} > <FormControl invalid={!isValid} > <label >Course Goal</label> <input type='text' onChange={goalInputChangeHandler} key='GoalInput' /> </FormControl> <Button type="submit">Add Goal</Button> </form> ); }; export default CourseInput;
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!