Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure withI18n hoists static members. Fixes #583. #584

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@
"!**/example/**"
]
},
"prettier": {
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100
},
"lock": false
}
141 changes: 115 additions & 26 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@
}

function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
}

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}

/** @license React v16.5.2
/** @license React v16.6.0
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -405,11 +405,13 @@
g = b ? Symbol.for("react.profiler") : 60114,
h = b ? Symbol.for("react.provider") : 60109,
k = b ? Symbol.for("react.context") : 60110,
l = b ? Symbol.for("react.async_mode") : 60111,
l = b ? Symbol.for("react.concurrent_mode") : 60111,
m = b ? Symbol.for("react.forward_ref") : 60112,
n = b ? Symbol.for("react.placeholder") : 60113;
n = b ? Symbol.for("react.suspense") : 60113,
q = b ? Symbol.for("react.memo") : 60115,
r = b ? Symbol.for("react.lazy") : 60116;

function q(a) {
function t(a) {
if ("object" === _typeof(a) && null !== a) {
var p = a.$$typeof;

Expand Down Expand Up @@ -441,8 +443,13 @@
}
}

exports.typeOf = q;
function u(a) {
return t(a) === l;
}

exports.typeOf = t;
exports.AsyncMode = l;
exports.ConcurrentMode = l;
exports.ContextConsumer = k;
exports.ContextProvider = h;
exports.Element = c;
Expand All @@ -453,50 +460,52 @@
exports.StrictMode = f;

exports.isValidElementType = function (a) {
return "string" === typeof a || "function" === typeof a || a === e || a === l || a === g || a === f || a === n || "object" === _typeof(a) && null !== a && ("function" === typeof a.then || a.$$typeof === h || a.$$typeof === k || a.$$typeof === m);
return "string" === typeof a || "function" === typeof a || a === e || a === l || a === g || a === f || a === n || "object" === _typeof(a) && null !== a && (a.$$typeof === r || a.$$typeof === q || a.$$typeof === h || a.$$typeof === k || a.$$typeof === m);
};

exports.isAsyncMode = function (a) {
return q(a) === l;
return u(a);
};

exports.isConcurrentMode = u;

exports.isContextConsumer = function (a) {
return q(a) === k;
return t(a) === k;
};

exports.isContextProvider = function (a) {
return q(a) === h;
return t(a) === h;
};

exports.isElement = function (a) {
return "object" === _typeof(a) && null !== a && a.$$typeof === c;
};

exports.isForwardRef = function (a) {
return q(a) === m;
return t(a) === m;
};

exports.isFragment = function (a) {
return q(a) === e;
return t(a) === e;
};

exports.isProfiler = function (a) {
return q(a) === g;
return t(a) === g;
};

exports.isPortal = function (a) {
return q(a) === d;
return t(a) === d;
};

exports.isStrictMode = function (a) {
return q(a) === f;
return t(a) === f;
};

var reactIs_production_min = /*#__PURE__*/Object.freeze({

});

/** @license React v16.5.2
/** @license React v16.6.0
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -521,14 +530,71 @@
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;

function isValidElementType(type) {
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || _typeof(type) === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || _typeof(type) === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
}
/**
* Forked from fbjs/warning:
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
*
* Only change is we use console.warn instead of console.error,
* and do nothing when 'console' is not supported.
* This really simplifies the code.
* ---
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/


var lowPriorityWarning = function lowPriorityWarning() {};

{
var printWarning = function printWarning(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}

var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});

if (typeof console !== 'undefined') {
console.warn(message);
}

try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};

lowPriorityWarning = function lowPriorityWarning(condition, format) {
if (format === undefined) {
throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
}

if (!condition) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}

printWarning.apply(undefined, [format].concat(args));
}
};
}
var lowPriorityWarning$1 = lowPriorityWarning;

function typeOf(object) {
if (_typeof(object) === 'object' && object !== null) {
Expand All @@ -539,7 +605,7 @@
var type = object.type;

switch (type) {
case REACT_ASYNC_MODE_TYPE:
case REACT_CONCURRENT_MODE_TYPE:
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
Expand All @@ -566,9 +632,11 @@
}

return undefined;
}
} // AsyncMode alias is deprecated along with isAsyncMode

var AsyncMode = REACT_ASYNC_MODE_TYPE;

var AsyncMode = REACT_CONCURRENT_MODE_TYPE;
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
Expand All @@ -577,9 +645,20 @@
var Profiler = REACT_PROFILER_TYPE;
var Portal = REACT_PORTAL_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated

function isAsyncMode(object) {
return typeOf(object) === REACT_ASYNC_MODE_TYPE;
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true;
lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
}
}
return isConcurrentMode(object);
}

function isConcurrentMode(object) {
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
}

function isContextConsumer(object) {
Expand Down Expand Up @@ -616,6 +695,7 @@

exports.typeOf = typeOf;
exports.AsyncMode = AsyncMode;
exports.ConcurrentMode = ConcurrentMode;
exports.ContextConsumer = ContextConsumer;
exports.ContextProvider = ContextProvider;
exports.Element = Element;
Expand All @@ -626,6 +706,7 @@
exports.StrictMode = StrictMode;
exports.isValidElementType = isValidElementType;
exports.isAsyncMode = isAsyncMode;
exports.isConcurrentMode = isConcurrentMode;
exports.isContextConsumer = isContextConsumer;
exports.isContextProvider = isContextProvider;
exports.isElement = isElement;
Expand Down Expand Up @@ -1063,8 +1144,13 @@
return WithContext;
};
}

function getDisplayName(component) {
return component.displayName || component.name || 'Component';
}
/* eslint-disable react/no-multi-comp */


function withI18n() {
return function Wrapper(WrappedComponent) {
var WithMergedOptions =
Expand Down Expand Up @@ -1118,7 +1204,10 @@
return WithMergedOptions;
}(React.Component);

return withContext()(WithMergedOptions);
var WithMergedOptionsWithContext = withContext()(WithMergedOptions);
WithMergedOptionsWithContext.WrappedComponent = WrappedComponent;
WithMergedOptionsWithContext.displayName = "WithMergedOptions(".concat(getDisplayName(WrappedComponent), ")");
return hoistNonReactStatics_cjs(WithMergedOptionsWithContext, WrappedComponent);
};
}

Expand Down Expand Up @@ -1328,7 +1417,7 @@
return React__default.createElement(NamespacesConsumer, props);
}

function getDisplayName(component) {
function getDisplayName$1(component) {
return component.displayName || component.name || 'Component';
}

Expand Down Expand Up @@ -1394,7 +1483,7 @@

var LoadNamespaceWithContext = withI18n()(LoadNamespace);
LoadNamespaceWithContext.WrappedComponent = WrappedComponent;
LoadNamespaceWithContext.displayName = "LoadNamespace(".concat(getDisplayName(WrappedComponent), ")");
LoadNamespaceWithContext.displayName = "LoadNamespace(".concat(getDisplayName$1(WrappedComponent), ")");
LoadNamespaceWithContext.namespaces = namespaceArg;
return hoistNonReactStatics_cjs(LoadNamespaceWithContext, WrappedComponent);
};
Expand Down
Loading