Skip to content

Commit c680192

Browse files
committed
update to use prop-types in react 15.5.x
1 parent b3d4d53 commit c680192

File tree

5 files changed

+97
-75
lines changed

5 files changed

+97
-75
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 3.0.0
2+
- [BREAKING] assert you install prop-types as a peerDependency based on changes in react >= 15.5.x
3+
- update react to 15.5.x use prop-types module to remove react warnings [PR248](https://github.com/i18next/react-i18next/pull/248)
4+
- update all dependencies
5+
- move react, prop-types to peerDependencies
6+
17
### 2.2.3
28
- try not access store if undefined for hmr
39

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,37 @@
2525
"hoist-non-react-statics": "1.2.0"
2626
},
2727
"devDependencies": {
28-
"babel-cli": "6.11.4",
29-
"babel-core": "6.13.2",
30-
"babel-eslint": "6.1.2",
31-
"babel-jest": "14.1.0",
32-
"babel-preset-es2015": "6.13.2",
33-
"babel-preset-es2015-rollup": "1.2.0",
34-
"babel-preset-stage-0": "6.5.0",
35-
"babel-register": "6.11.6",
28+
"babel-cli": "6.24.1",
29+
"babel-core": "6.24.1",
30+
"babel-eslint": "7.2.1",
31+
"babel-jest": "19.0.0",
32+
"babel-preset-es2015": "6.24.1",
33+
"babel-preset-es2015-rollup": "3.0.0",
34+
"babel-preset-stage-0": "6.24.1",
35+
"babel-register": "6.24.1",
3636
"coveralls": "^2.11.12",
37-
"enzyme": "2.4.1",
38-
"eslint": "3.3.1",
39-
"eslint-config-airbnb": "10.0.1",
40-
"eslint-plugin-import": "1.13.0",
41-
"eslint-plugin-jsx-a11y": "2.1.0",
42-
"eslint-plugin-react": "6.1.2",
43-
"i18next": "3.4.1",
44-
"jest": "14.1.0",
45-
"jest-cli": "14.1.0",
37+
"enzyme": "2.8.0",
38+
"eslint": "3.19.0",
39+
"eslint-config-airbnb": "14.1.0",
40+
"eslint-plugin-import": "2.2.0",
41+
"eslint-plugin-jsx-a11y": "4.0.0",
42+
"eslint-plugin-react": "6.10.3",
43+
"i18next": "7.1.3",
44+
"jest": "19.0.2",
45+
"jest-cli": "19.0.2",
4646
"mkdirp": "0.5.1",
47-
"react": "15.3.0",
48-
"prop-types": "15.5.6",
49-
"rimraf": "2.5.4",
50-
"rollup": "0.34.10",
51-
"rollup-plugin-babel": "2.6.1",
52-
"rollup-plugin-commonjs": "3.3.1",
53-
"rollup-plugin-node-resolve": "2.0.0",
47+
"rimraf": "2.6.1",
48+
"rollup": "0.41.6",
49+
"rollup-plugin-babel": "2.7.1",
50+
"rollup-plugin-commonjs": "8.0.2",
51+
"rollup-plugin-node-resolve": "3.0.0",
5452
"rollup-plugin-uglify": "1.0.1",
55-
"yargs": "5.0.0"
53+
"yargs": "7.0.2"
5654
},
5755
"peerDependencies": {
58-
"i18next": ">= 6.0.1"
56+
"i18next": ">= 6.0.1",
57+
"react": ">= 15.0.0",
58+
"prop-types": ">= 15.0.0"
5959
},
6060
"scripts": {
6161
"clean": "rimraf dist && mkdirp dist",

react-i18next.js

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
(function (global, factory) {
22
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types')) :
33
typeof define === 'function' && define.amd ? define('reactI18next', ['exports', 'react', 'prop-types'], factory) :
4-
(factory((global.reactI18next = global.reactI18next || {}),global.React));
4+
(factory((global.reactI18next = global.reactI18next || {}),global.React,global.PropTypes));
55
}(this, (function (exports,React,PropTypes) { 'use strict';
66

77
var React__default = 'default' in React ? React['default'] : React;
8+
PropTypes = 'default' in PropTypes ? PropTypes['default'] : PropTypes;
89

9-
function interopDefault(ex) {
10-
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex;
11-
}
12-
13-
function createCommonjsModule(fn, module) {
14-
return module = { exports: {} }, fn(module, module.exports), module.exports;
15-
}
16-
17-
var index = createCommonjsModule(function (module) {
1810
/**
1911
* Copyright 2015, Yahoo! Inc.
2012
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2113
*/
22-
'use strict';
23-
2414
var REACT_STATICS = {
2515
childContextTypes: true,
2616
contextTypes: true,
@@ -43,7 +33,7 @@ var KNOWN_STATICS = {
4333

4434
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
4535

46-
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
36+
var index = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
4737
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
4838
var keys = Object.getOwnPropertyNames(sourceComponent);
4939

@@ -65,16 +55,23 @@ module.exports = function hoistNonReactStatics(targetComponent, sourceComponent,
6555

6656
return targetComponent;
6757
};
68-
});
69-
70-
var hoistStatics = interopDefault(index);
7158

7259
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
7360
return typeof obj;
7461
} : function (obj) {
75-
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
62+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
7663
};
7764

65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
7875
var classCallCheck = function (instance, Constructor) {
7976
if (!(instance instanceof Constructor)) {
8077
throw new TypeError("Cannot call a class as a function");
@@ -99,6 +96,10 @@ var createClass = function () {
9996
};
10097
}();
10198

99+
100+
101+
102+
102103
var defineProperty = function (obj, key, value) {
103104
if (key in obj) {
104105
Object.defineProperty(obj, key, {
@@ -128,6 +129,8 @@ var _extends = Object.assign || function (target) {
128129
return target;
129130
};
130131

132+
133+
131134
var inherits = function (subClass, superClass) {
132135
if (typeof superClass !== "function" && superClass !== null) {
133136
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
@@ -144,6 +147,16 @@ var inherits = function (subClass, superClass) {
144147
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
145148
};
146149

150+
151+
152+
153+
154+
155+
156+
157+
158+
159+
147160
var possibleConstructorReturn = function (self, call) {
148161
if (!self) {
149162
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -152,6 +165,10 @@ var possibleConstructorReturn = function (self, call) {
152165
return call && (typeof call === "object" || typeof call === "function") ? call : self;
153166
};
154167

168+
169+
170+
171+
155172
var slicedToArray = function () {
156173
function sliceIterator(arr, i) {
157174
var _arr = [];
@@ -195,17 +212,17 @@ function getDisplayName(component) {
195212
}
196213

197214
function translate(namespaces) {
198-
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
199-
var _options$withRef = options.withRef;
200-
var withRef = _options$withRef === undefined ? false : _options$withRef;
201-
var _options$wait = options.wait;
202-
var wait = _options$wait === undefined ? false : _options$wait;
203-
var _options$bindI18n = options.bindI18n;
204-
var bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n;
205-
var _options$bindStore = options.bindStore;
206-
var bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore;
207-
var _options$translateFun = options.translateFuncName;
208-
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
215+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216+
var _options$withRef = options.withRef,
217+
withRef = _options$withRef === undefined ? false : _options$withRef,
218+
_options$wait = options.wait,
219+
wait = _options$wait === undefined ? false : _options$wait,
220+
_options$bindI18n = options.bindI18n,
221+
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
222+
_options$bindStore = options.bindStore,
223+
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
224+
_options$translateFun = options.translateFuncName,
225+
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
209226

210227

211228
return function Wrapper(WrappedComponent) {
@@ -215,7 +232,7 @@ function translate(namespaces) {
215232
function Translate(props, context) {
216233
classCallCheck(this, Translate);
217234

218-
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Translate).call(this, props, context));
235+
var _this = possibleConstructorReturn(this, (Translate.__proto__ || Object.getPrototypeOf(Translate)).call(this, props, context));
219236

220237
_this.i18n = context.i18n || props.i18n;
221238
namespaces = namespaces || _this.i18n.options.defaultNS;
@@ -312,9 +329,9 @@ function translate(namespaces) {
312329
value: function render() {
313330
var _extraProps;
314331

315-
var _state = this.state;
316-
var i18nLoadedAt = _state.i18nLoadedAt;
317-
var ready = _state.ready;
332+
var _state = this.state,
333+
i18nLoadedAt = _state.i18nLoadedAt,
334+
ready = _state.ready;
318335

319336
var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
320337

@@ -342,7 +359,7 @@ function translate(namespaces) {
342359

343360
Translate.namespaces = namespaces;
344361

345-
return hoistStatics(Translate, WrappedComponent);
362+
return index(Translate, WrappedComponent);
346363
};
347364
}
348365

@@ -352,7 +369,7 @@ var Interpolate = function (_Component) {
352369
function Interpolate(props, context) {
353370
classCallCheck(this, Interpolate);
354371

355-
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Interpolate).call(this, props, context));
372+
var _this = possibleConstructorReturn(this, (Interpolate.__proto__ || Object.getPrototypeOf(Interpolate)).call(this, props, context));
356373

357374
_this.i18n = context.i18n;
358375
_this.t = context.t;
@@ -366,9 +383,9 @@ var Interpolate = function (_Component) {
366383

367384
var parent = this.props.parent || 'span';
368385
var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
369-
var _props = this.props;
370-
var className = _props.className;
371-
var style = _props.style;
386+
var _props = this.props,
387+
className = _props.className,
388+
style = _props.style;
372389

373390
// Set to true if you want to use raw HTML in translation values
374391
// See https://github.com/i18next/react-i18next/issues/189
@@ -437,7 +454,7 @@ var I18nextProvider = function (_Component) {
437454
function I18nextProvider(props, context) {
438455
classCallCheck(this, I18nextProvider);
439456

440-
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(I18nextProvider).call(this, props, context));
457+
var _this = possibleConstructorReturn(this, (I18nextProvider.__proto__ || Object.getPrototypeOf(I18nextProvider)).call(this, props, context));
441458

442459
_this.i18n = props.i18n;
443460
return _this;
@@ -486,10 +503,9 @@ function eachComponents(components, iterator) {
486503

487504
try {
488505
for (var _iterator = Object.entries(components[i])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
489-
var _step$value = slicedToArray(_step.value, 2);
490-
491-
var key = _step$value[0];
492-
var value = _step$value[1];
506+
var _step$value = slicedToArray(_step.value, 2),
507+
key = _step$value[0],
508+
value = _step$value[1];
493509

494510
iterator(value, i, key);
495511
}
@@ -515,10 +531,10 @@ function eachComponents(components, iterator) {
515531

516532
function filterAndFlattenComponents(components) {
517533
var flattened = [];
518-
eachComponents(components, function (Component) {
519-
if (Component && Component.namespaces) {
534+
eachComponents(components, function (Component$$1) {
535+
if (Component$$1 && Component$$1.namespaces) {
520536

521-
Component.namespaces.forEach(function (namespace) {
537+
Component$$1.namespaces.forEach(function (namespace) {
522538
if (flattened.indexOf(namespace) === -1) {
523539
flattened.push(namespace);
524540
}
@@ -529,8 +545,8 @@ function filterAndFlattenComponents(components) {
529545
}
530546

531547
function loadNamespaces(_ref) {
532-
var components = _ref.components;
533-
var i18n = _ref.i18n;
548+
var components = _ref.components,
549+
i18n = _ref.i18n;
534550

535551
var allNamespaces = filterAndFlattenComponents(components);
536552

0 commit comments

Comments
 (0)