Skip to content

Commit

Permalink
Merge pull request #191 from AppQuality/develop
Browse files Browse the repository at this point in the history
feat: Reload timepicker internal value on prop change (#190)
  • Loading branch information
d-beezee authored Apr 29, 2024
2 parents 1bd0aef + 8bf6669 commit b9c4055
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/stories/form/datepicker/TimePicker.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 (
<StyledInput type="text">
<InputMask
Expand Down

0 comments on commit b9c4055

Please sign in to comment.