Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 62db909

Browse files
authored
Merge pull request #170 from strapi/develop
3.3.3
2 parents 420d708 + 9677e0f commit 62db909

File tree

2 files changed

+6
-15
lines changed
  • packages
    • buffetjs-core/src/components/DatePicker
    • buffetjs-custom/src/components/DateTime

2 files changed

+6
-15
lines changed

packages/buffetjs-core/src/components/DatePicker/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ function Datepicker({
5858
type: 'SET_DISPLAYED_DATE',
5959
displayedDate,
6060
});
61-
// eslint-disable-next-line react-hooks/exhaustive-deps
62-
}, []);
61+
}, [value, withDefaultValue]);
6362

6463
let timer = null;
6564
const { date, displayedDate, isFocused, isVisible } = state;

packages/buffetjs-custom/src/components/DateTime/index.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function DateTime({
4747
...rest
4848
}) {
4949
const [timestamp, setTimestamp] = useState(null);
50-
const [isInit, setIsInit] = useState(false);
50+
5151
const setData = time => {
5252
const [hour, minute, second] = time.split(':');
5353
const timeObj = {
@@ -84,20 +84,12 @@ function DateTime({
8484
};
8585

8686
useEffect(() => {
87-
if (!isInit) {
88-
if (!!value && moment(value).isValid()) {
89-
const newDate = value._isAMomentObject === true ? value : moment(value);
90-
91-
setTimestamp(newDate);
92-
}
87+
if (!!value && moment(value).isValid()) {
88+
const newDate = value._isAMomentObject === true ? value : moment(value);
9389

94-
setIsInit(true);
90+
setTimestamp(newDate);
9591
}
96-
}, [isInit, value]);
97-
98-
if (!isInit) {
99-
return null;
100-
}
92+
}, [value]);
10193

10294
return (
10395
<Wrapper>

0 commit comments

Comments
 (0)