I juste created a custom hook to update a value from a calendar picker, and getting it updated in a Form component.
export const useCalendar = (props) => {
const [startDate, setStartDate] = useState("");
useEffect(() => {
console.log("startDate 2", startDate);
}, [startDate]);
return {startDate, setStartDate}
};
export const CalendarPicker = () => {
const { startDate, setStartDate } = useCalendar();
const handleDayPress = (newDateObject) => {
setStartDate(newDateObject);
}
};
export const Form = () => {
const { startDate } = useCalendar();
useEffect(() => {
console.log("startDate", startDate);
}, [startDate]);
}
The value is getting updated in the custom Hook but not in the Form component
Getting the value updated from the custom Hook to the Form