Skip to content

Commit

Permalink
Add support for react 17 (gpbl#696)
Browse files Browse the repository at this point in the history
* Add react-lifecycles-compat

* Use polyfill from react-lifecycles-compat when required
  • Loading branch information
gpbl authored Apr 14, 2018
1 parent fce5167 commit 9424352
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"webpack": "3.10.0"
},
"dependencies": {
"prop-types": "^15.6.1"
"prop-types": "^15.6.1",
"react-lifecycles-compat": "^3.0.2"
}
}
7 changes: 6 additions & 1 deletion src/DayPicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import { polyfill } from 'react-lifecycles-compat';
import PropTypes from 'prop-types';

import Caption from './Caption';
Expand All @@ -14,7 +15,7 @@ import classNames from './classNames';

import { ENTER, SPACE, LEFT, UP, DOWN, RIGHT } from './keys';

export default class DayPicker extends Component {
export class _DayPicker extends Component {
static VERSION = '7.1.4';

static propTypes = {
Expand Down Expand Up @@ -575,6 +576,10 @@ export default class DayPicker extends Component {
}
}

const DayPicker = polyfill(_DayPicker);

DayPicker.DateUtils = DateUtils;
DayPicker.LocaleUtils = LocaleUtils;
DayPicker.ModifiersUtils = ModifiersUtils;

export default DayPicker;
6 changes: 5 additions & 1 deletion src/DayPickerInput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { polyfill } from 'react-lifecycles-compat';
import PropTypes from 'prop-types';

import DayPicker from './DayPicker';
Expand Down Expand Up @@ -48,7 +49,7 @@ export function defaultParse(str) {
return new Date(year, month, day);
}

export default class DayPickerInput extends React.Component {
export class _DayPickerInput extends React.Component {
static propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
inputProps: PropTypes.object,
Expand Down Expand Up @@ -499,3 +500,6 @@ export default class DayPickerInput extends React.Component {
);
}
}

const DayPickerInput = polyfill(_DayPickerInput);
export default DayPickerInput;
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4955,6 +4955,10 @@ react-dom@16.2.0:
object-assign "^4.1.1"
prop-types "^15.6.0"

react-lifecycles-compat@3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.2.tgz#7279047275bd727a912e25f734c0559527e84eff"

react-reconciler@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.7.0.tgz#9614894103e5f138deeeb5eabaf3ee80eb1d026d"
Expand Down

0 comments on commit 9424352

Please sign in to comment.