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

196
Views
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 answers
Answer question

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 Report
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!