Skip to content

Commit b3d4d53

Browse files
authored
Merge pull request i18next#248 from kadishmal/247
Fix i18next#247: PropTypes warnings.
2 parents 42d1a7b + 9f60a3c commit b3d4d53

File tree

9 files changed

+31
-24
lines changed

9 files changed

+31
-24
lines changed

__tests__/i18nextProvider-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
jest.unmock('../src/I18nextProvider');
22
import React from 'react';
3+
import PropTypes from 'prop-types';
34
import I18nextProvider from '../src/I18nextProvider' ;
45

56
describe('I18nextProvider', () => {
@@ -8,7 +9,7 @@ describe('I18nextProvider', () => {
89
const wrapper = new I18nextProvider({ i18n });
910
expect(wrapper.getChildContext().i18n).toBe(i18n);
1011
expect(I18nextProvider.childContextTypes.i18n)
11-
.toBe(React.PropTypes.object.isRequired);
12+
.toBe(PropTypes.object.isRequired);
1213
});
1314
it('should throw an exception if you try to change i18n object', () => {
1415
const i18n = {};
@@ -28,10 +29,10 @@ describe('I18nextProvider', () => {
2829
});
2930
it('should have i18n proptype required', () => {
3031
expect(I18nextProvider.propTypes.i18n)
31-
.toBe(React.PropTypes.object.isRequired);
32+
.toBe(PropTypes.object.isRequired);
3233
});
3334
it('should have children proptype required', () => {
3435
expect(I18nextProvider.propTypes.children)
35-
.toBe(React.PropTypes.element.isRequired);
36+
.toBe(PropTypes.element.isRequired);
3637
});
3738
});

__tests__/interpolate-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
jest.unmock('../src/translate');
22
import React from 'react';
3+
import PropTypes from 'prop-types';
34
import Interpolate from '../src/interpolate';
45

56
describe('interpolate', () => {
67
it('should have some stuff', () => {
78
expect(Interpolate.contextTypes.i18n)
8-
.toBe(React.PropTypes.object.isRequired);
9+
.toBe(PropTypes.object.isRequired);
910
expect(Interpolate.contextTypes.t)
10-
.toBe(React.PropTypes.func.isRequired);
11+
.toBe(PropTypes.func.isRequired);
1112
const props = {};
1213
const context = {
1314
i18n: {},

__tests__/translate-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
jest.unmock('../src/translate');
22
import React from 'react';
3+
import PropTypes from 'prop-types';
34
import translate from '../src/translate';
45

56
describe('translate', () => {
@@ -14,8 +15,8 @@ describe('translate', () => {
1415
Elem.NOT_KNOWN_REACT_STATIC = 'IS HOISTED ?';
1516
const wrapped = wrap(Elem);
1617
expect(wrapped.WrappedComponent).toBe(Elem);
17-
expect(wrapped.contextTypes.i18n).toBe(React.PropTypes.object);
18-
expect(wrapped.childContextTypes.t).toBe(React.PropTypes.func.isRequired);
18+
expect(wrapped.contextTypes.i18n).toBe(PropTypes.object);
19+
expect(wrapped.childContextTypes.t).toBe(PropTypes.func.isRequired);
1920
expect(wrapped.displayName).toBe('Translate(Elem)');
2021
expect(wrapped.namespaces.length).toBe(2);
2122
expect(wrapped.namespaces[0]).toBe('ns1');

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"jest-cli": "14.1.0",
4646
"mkdirp": "0.5.1",
4747
"react": "15.3.0",
48+
"prop-types": "15.5.6",
4849
"rimraf": "2.5.4",
4950
"rollup": "0.34.10",
5051
"rollup-plugin-babel": "2.6.1",

react-i18next.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(function (global, factory) {
2-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3-
typeof define === 'function' && define.amd ? define('reactI18next', ['exports', 'react'], factory) :
2+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types')) :
3+
typeof define === 'function' && define.amd ? define('reactI18next', ['exports', 'react', 'prop-types'], factory) :
44
(factory((global.reactI18next = global.reactI18next || {}),global.React));
5-
}(this, (function (exports,React) { 'use strict';
5+
}(this, (function (exports,React,PropTypes) { 'use strict';
66

77
var React__default = 'default' in React ? React['default'] : React;
88

@@ -333,10 +333,10 @@ function translate(namespaces) {
333333
Translate.WrappedComponent = WrappedComponent;
334334

335335
Translate.contextTypes = {
336-
i18n: React.PropTypes.object
336+
i18n: PropTypes.object
337337
};
338338

339-
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);
339+
Translate.childContextTypes = defineProperty({}, translateFuncName, PropTypes.func.isRequired);
340340

341341
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
342342

@@ -422,13 +422,13 @@ var Interpolate = function (_Component) {
422422
}(React.Component);
423423

424424
Interpolate.propTypes = {
425-
children: React.PropTypes.node,
426-
className: React.PropTypes.string
425+
children: PropTypes.node,
426+
className: PropTypes.string
427427
};
428428

429429
Interpolate.contextTypes = {
430-
i18n: React.PropTypes.object.isRequired,
431-
t: React.PropTypes.func.isRequired
430+
i18n: PropTypes.object.isRequired,
431+
t: PropTypes.func.isRequired
432432
};
433433

434434
var I18nextProvider = function (_Component) {
@@ -467,12 +467,12 @@ var I18nextProvider = function (_Component) {
467467
}(React.Component);
468468

469469
I18nextProvider.propTypes = {
470-
i18n: React.PropTypes.object.isRequired,
471-
children: React.PropTypes.element.isRequired
470+
i18n: PropTypes.object.isRequired,
471+
children: PropTypes.element.isRequired
472472
};
473473

474474
I18nextProvider.childContextTypes = {
475-
i18n: React.PropTypes.object.isRequired
475+
i18n: PropTypes.object.isRequired
476476
};
477477

478478
// Borrowed from https://github.com/Rezonans/redux-async-connect/blob/master/modules/ReduxAsyncConnect.js#L16
@@ -546,4 +546,4 @@ exports.I18nextProvider = I18nextProvider;
546546

547547
Object.defineProperty(exports, '__esModule', { value: true });
548548

549-
})));
549+
})));

react-i18next.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/I18nextProvider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, PropTypes, Children } from 'react';
1+
import { Component, Children } from 'react';
2+
import PropTypes from 'prop-types';
23

34
class I18nextProvider extends Component {
45
constructor(props, context) {

src/interpolate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
23

34
class Interpolate extends Component {
45

src/translate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
23
import hoistStatics from 'hoist-non-react-statics';
34

45
function getDisplayName(component) {

0 commit comments

Comments
 (0)