From 8bf66690d9dab8c70e4a3a3ccce1c95291841a68 Mon Sep 17 00:00:00 2001 From: d-beezee <59012086+d-beezee@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:07:53 +0200 Subject: [PATCH] feat: Reload timepicker internal value on prop change (#190) --- src/stories/form/datepicker/TimePicker.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stories/form/datepicker/TimePicker.tsx b/src/stories/form/datepicker/TimePicker.tsx index ce7c6c8..6e400c9 100644 --- a/src/stories/form/datepicker/TimePicker.tsx +++ b/src/stories/form/datepicker/TimePicker.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import InputMask, { InputState } from "react-input-mask"; import { StyledInput } from "../input/Input"; import { DatepickerProps } from "./_types"; @@ -35,6 +35,12 @@ const TimePicker = ({ const [time, setTime] = useState( value ? (typeof value === "string" ? value : formatTime(value)) : "", ); + + useEffect(() => { + setTime( + value ? (typeof value === "string" ? value : formatTime(value)) : "", + ); + }, [value]); return (