Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
input initial Value react js

I have questionand I hope you can help me to find right answer.

I have the following code.

    import Slider from '@material-ui/core/Slider';

    export default function RangeSlider({setValue1}) {
    const location = useLocation();
    const classes = useStyles();
    const [value, setValue] = useState(['', 150000]);
    const handleChange = (event, newValue) => {
    setValue(newValue);
    setValue1(value);
   };

    useEffect(() => {
    setValue(['', 150000]);
    setValue1(value);
    }, [location.search]);

    return (
    <div className={`filter-slider-wrapper ${classes.root} `}>
      <p>
        <input
          type="number"
          className="slider-input"
          onChange={({target}) => {
            if (target.value.length > 7) {
              return false;
            }
            setValue([+target.value, value[1]]);
            setValue1(value);
          }}
          value={value[0]}
        />
      </p>
      <Slider value={value} onChange={handleChange} min={1} max={150000} />
      <p>
        <input
          type="number"
          className="slider-input"
          onChange={({target}) => {
            if (target.value.length > 7) {
              return false;
            }
            setValue([value[0], +target.value]);
            setValue1(value);
          }}
          value={value[1]}
        />
      </p>
    </div>
    );
   }

When I typeing something in input and after that I delleting form input everything was deleted, but after that "0" number was appeared and it was not deleteable, how can I avoid that case?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Thank you everybody.

I alredy resolved this problem.

I just deleted "+" symbol in setValue([+target.value, value[1]]);

Now the correct way to avoid "0" number to write without "+" symbol

Right way is: setValue([target.value, value[1]]);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda