This repository was archived by the owner on Mar 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed
buffetjs-core/src/components/DatePicker
buffetjs-custom/src/components/DateTime Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,7 @@ function Datepicker({
58
58
type : 'SET_DISPLAYED_DATE' ,
59
59
displayedDate,
60
60
} ) ;
61
- // eslint-disable-next-line react-hooks/exhaustive-deps
62
- } , [ ] ) ;
61
+ } , [ value , withDefaultValue ] ) ;
63
62
64
63
let timer = null ;
65
64
const { date, displayedDate, isFocused, isVisible } = state ;
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ function DateTime({
47
47
...rest
48
48
} ) {
49
49
const [ timestamp , setTimestamp ] = useState ( null ) ;
50
- const [ isInit , setIsInit ] = useState ( false ) ;
50
+
51
51
const setData = time => {
52
52
const [ hour , minute , second ] = time . split ( ':' ) ;
53
53
const timeObj = {
@@ -84,20 +84,12 @@ function DateTime({
84
84
} ;
85
85
86
86
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 ) ;
93
89
94
- setIsInit ( true ) ;
90
+ setTimestamp ( newDate ) ;
95
91
}
96
- } , [ isInit , value ] ) ;
97
-
98
- if ( ! isInit ) {
99
- return null ;
100
- }
92
+ } , [ value ] ) ;
101
93
102
94
return (
103
95
< Wrapper >
You can’t perform that action at this time.
0 commit comments