Skip to content

Commit

Permalink
Fixes use of invalid React string based ref
Browse files Browse the repository at this point in the history
React has deprecated string based refs. Converted to a `createRef()` version.
  • Loading branch information
getdave committed Jan 29, 2019
1 parent d5cf4f1 commit 41ae862
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions client/components/date-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DatePicker extends PureComponent {
onDayMouseLeave: PropTypes.func,
toMonth: PropTypes.object,
fromMonth: PropTypes.object,
onDayTouchStart: PropTypes.func,
onDayTouchStart: PropTypes.func,
onDayTouchEnd: PropTypes.func,
onDayTouchMove: PropTypes.func,
rootClassNames: PropTypes.object,
Expand All @@ -78,6 +78,12 @@ class DatePicker extends PureComponent {
rootClassNames: {},
};

constructor( props ) {
super( props );

this.dayPickerRef = React.createRef();
}

isSameDay( d0, d1 ) {
d0 = this.props.moment( d0 );
d1 = this.props.moment( d1 );
Expand Down Expand Up @@ -231,13 +237,12 @@ class DatePicker extends PureComponent {
this.getDateInstance( event.date )
);
}

const numMonths = this.props.numberOfMonths || 1;
const rangeSelected = modifiers.start && modifiers.end;

if ( hasDateRange ) {
const numMonths = this.props.numberOfMonths || 1;
const rangeSelected = modifiers.start && modifiers.end;

modifiers[ 'range-start' ] = this.props.selectedDays.from;
if ( hasDateRange ) {
modifiers[ 'range-start' ] = this.props.selectedDays.from;
modifiers[ 'range-end' ] = this.props.selectedDays.to;
modifiers.range = {
from: this.props.selectedDays.from,
Expand All @@ -256,7 +261,7 @@ class DatePicker extends PureComponent {
return (
<DayPicker
modifiers={ modifiers }
ref="daypicker"
ref={ this.dayPickerRef }
className={ rootClassNames }
disabledDays={ this.props.disabledDays }
initialMonth={ this.props.calendarInitialDate }
Expand Down

0 comments on commit 41ae862

Please sign in to comment.