Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
Converted monthLabel to const; purgeEdits, open and close now have us…
Browse files Browse the repository at this point in the history
…eCallback #899
  • Loading branch information
daniel-martic-sociomantic committed Feb 27, 2019
1 parent d686f0a commit c63a7bb
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/DateTimeInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ const DateTimeInput = React.forwardRef( ( props, ref ) =>
return _.chunk( days, 7 );
};


const monthMatrix = () =>
{
const startYear = gridStartTimestamp;
Expand Down Expand Up @@ -469,24 +470,20 @@ const DateTimeInput = React.forwardRef( ( props, ref ) =>
};


const monthLabel = () =>
{
const month = $m( gridStartTimestamp ).month();
return copy.months[ month ];
};
const monthLabel = copy.months[ $m( gridStartTimestamp ).month() ];

const yearLabel = () => $m( gridStartTimestamp ).year().toString();


const purgeEdits = () =>
const purgeEdits = useCallback( () =>
{
setEditingHourInputValue( undefined );
setEditingMainInputValue( undefined );
setEditingMinuteInputValue( undefined );
};
}, [] );


const open = () =>
const open = useCallback( () =>
{
const { min } = props;
let newTimestamp;
Expand All @@ -499,13 +496,13 @@ const DateTimeInput = React.forwardRef( ( props, ref ) =>
setGridStartTimestamp( $m( newTimestamp )
.startOf( props.mode === 'month' ? 'year' : 'month' )
.valueOf() );
};
}, [ props.min, props.mode, timestamp ] );

const close = () =>
const close = useCallback( () =>
{
purgeEdits();
setGridStartTimestamp( null );
};
}, [] );


const {
Expand Down Expand Up @@ -539,7 +536,7 @@ const DateTimeInput = React.forwardRef( ( props, ref ) =>
formatMinutes( timestamp )
}
mode = { mode }
month = { mode !== 'month' && monthLabel() }
month = { mode !== 'month' && monthLabel }
nextIsDisabled = { !canGotoNext() }
onChangeHour = { handleChangeHour }
onChangeMinute = { handleChangeMinute }
Expand Down

0 comments on commit c63a7bb

Please sign in to comment.