From 2cfd74a919281e1262d9a4fd87c671c71cb0c000 Mon Sep 17 00:00:00 2001 From: Viktor Hesselbom Date: Tue, 18 Apr 2017 11:33:23 +0200 Subject: [PATCH] Fix PropTypes warnings for React 15.5 --- lib/provider.js | 8 ++++++-- lib/reducer.js | 2 +- lib/withTranslate.js | 6 +++++- package.json | 2 +- src/provider.js | 3 ++- src/withTranslate.js | 3 ++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/provider.js b/lib/provider.js index 578097d..651a6e7 100644 --- a/lib/provider.js +++ b/lib/provider.js @@ -12,6 +12,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _reactRedux = require('react-redux'); var _utils = require('./utils'); @@ -30,7 +34,7 @@ var IntlProvider = function (_React$Component) { function IntlProvider(props) { _classCallCheck(this, IntlProvider); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(IntlProvider).call(this, props)); + var _this = _possibleConstructorReturn(this, (IntlProvider.__proto__ || Object.getPrototypeOf(IntlProvider)).call(this, props)); _this.translate = function (key, placeholders, isHTML) { var result = (0, _utils.translateKey)(key, _this.props.translations[_this.props.locale]['messages']); @@ -65,7 +69,7 @@ var IntlProvider = function (_React$Component) { }(_react2.default.Component); IntlProvider.childContextTypes = { - translate: _react2.default.PropTypes.func + translate: _propTypes2.default.func }; diff --git a/lib/reducer.js b/lib/reducer.js index d43b7a8..442c76a 100644 --- a/lib/reducer.js +++ b/lib/reducer.js @@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = function () { - var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0]; + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; switch (action.type) { diff --git a/lib/withTranslate.js b/lib/withTranslate.js index d034758..7c92ed5 100644 --- a/lib/withTranslate.js +++ b/lib/withTranslate.js @@ -10,6 +10,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _hoistNonReactStatics = require('hoist-non-react-statics'); var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics); @@ -26,7 +30,7 @@ exports.default = function (WrappedComponent) { }; WithTranslate.displayName = 'withTranslate(' + getComponentDisplayName(WrappedComponent) + ')'; WithTranslate.contextTypes = { - translate: _react2.default.PropTypes.func + translate: _propTypes2.default.func }; return (0, _hoistNonReactStatics2.default)(WithTranslate, WrappedComponent); }; \ No newline at end of file diff --git a/package.json b/package.json index bbc7757..5ee07b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-redux-multilingual", - "version": "1.0.2", + "version": "1.0.3", "description": "A simple multilingual translate component and HOC for react and redux", "main": "lib/index.js", "scripts": { diff --git a/src/provider.js b/src/provider.js index 2505ae7..6e6b6ba 100644 --- a/src/provider.js +++ b/src/provider.js @@ -1,4 +1,5 @@ import React, { Children } from 'react' +import PropTypes from 'prop-types' import { connect } from 'react-redux' import { supplant, translateKey, createHTMLMarkup } from './utils' @@ -11,7 +12,7 @@ class IntlProvider extends React.Component { } } static childContextTypes = { - translate: React.PropTypes.func + translate: PropTypes.func }; translate = (key, placeholders, isHTML) => { let result = translateKey(key, this.props.translations[this.props.locale]['messages']) diff --git a/src/withTranslate.js b/src/withTranslate.js index 81bf4d5..36b5930 100644 --- a/src/withTranslate.js +++ b/src/withTranslate.js @@ -1,4 +1,5 @@ import React from 'react' +import PropTypes from 'prop-types' import hoistNonReactStatics from 'hoist-non-react-statics' const getComponentDisplayName = (WrappedComponent) => { @@ -11,7 +12,7 @@ export default (WrappedComponent) => { } WithTranslate.displayName = `withTranslate(${getComponentDisplayName(WrappedComponent)})` WithTranslate.contextTypes = { - translate: React.PropTypes.func + translate: PropTypes.func } return hoistNonReactStatics(WithTranslate, WrappedComponent) }