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

155
Views
Cannot show on screen <Input> value

I'm trying to complete my project and now I need to show two counter respectively one for the start day and one for the end day of a prenotation. That's my current situation:

import  PrenotationContext  from '../context/PrenotationContext.jsx';
const Transactions = () => {
    const {currentAccount, places} = useContext(PrenotationContext);
    return (...
       <div>
        {places.reverse().map((place,i) => (
           <PlaceCard key={i} {...place} />
         ))}
        </div>
            ...
}

const PlaceCard = ({id, placeAddress,description,price, owner, isActive}) => {
  //implementation of prenotation
  const {isLoading,handleDate, rentPlace, setInactive} = useContext(PrenotationContext);

  const Input = ({placeholder, name, type, value, handleDate}) => (
    <input 
        placeholder={placeholder}
        type={type}
        step="1"
        value = {value}
        onChange={(e) => handleDate(e, name)}
    />
  );
  ...
return(
   <div>
    ...
    <Input placeholder="Start Day" name="startDay" type="number" handleDate={handleDate}/>
    <Input placeholder="End Day" name="endDay" type="number" handleDate={handleDate}/>
     ...
   </div>
);
export default Transactions

And here is PrenotationContext.json:

  export const PrenotationProvider = ({children}) => {
    ...
    const [date, setDate] = useState({startDay: 0, endDay:0});
    ...
    const handleDate = (e,name) => {
        console.log(e.target.value);
        console.log(name)
        setDate((prevState) => ({...prevState, [name]: e.target.value}))
    }
    ...
    return (
            <PrenotationContext.Provider 
               value={{...,
                       handleDate,
                       ...
                       isLoading,
                       setInactive,
            }}>
                {children}
            </PrenotationContext.Provider>
    );
};

The two logs in "handleDate" are the following:

  • (1, startDay) the first time
  • (-1, startDay) and so on for all the other times

and no value on screen

Instead trying to log the prevState inside handleDate (causing exception) will cause the logs and also on the webpage the correct output value (1,2,3...)

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!