Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda