Use React.isValidElement which covers non-Symbol supporting environments

This commit is contained in:
Daniel Leu 2018-10-15 12:23:20 +02:00
parent 5cc8c52385
commit 6ff3a2d103

View File

@ -20,7 +20,6 @@
import React from 'react';
import LocalizedStrings from 'localized-strings';
const isReactComponent = value => typeof value.$$typeof === 'symbol';
const placeholderRegex = /(\{[\d|\w]+\})/;
/**
@ -54,7 +53,7 @@ LocalizedStrings.prototype.formatString = (str, ...valuesForPlaceholders) => {
}
}
if(isReactComponent(valueForPlaceholder)) {
if(React.isValidElement(valueForPlaceholder)) {
hasObject = true;
return React.Children.toArray(valueForPlaceholder).map(component => ({...component, key: index.toString()}));
}