Skip to content

Commit b505c8a

Browse files
rxavierskborchers
authored andcommitted
Revert "Support react elements on properties"
This reverts commit fae8f30.
1 parent 1012dfc commit b505c8a

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

examples/components/messages.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var FormatMessage = require('../react-globalize').FormatMessage;
2-
var FormatNumber = require('../react-globalize').FormatNumber;
32
var React = require('react');
3+
var Globalize = require('globalize');
44

55
module.exports = React.createClass({
66
getInitialState: function() {
@@ -46,10 +46,7 @@ module.exports = React.createClass({
4646
<br/>
4747
task count 0 - <FormatMessage locale={this.state.locale} path="task" variables={{count: 0}} />
4848
<br/>
49-
task count 1000 formatted - <FormatMessage ref="formattedTask" locale={this.state.locale} path="task" variables={{
50-
count: 1000,
51-
formattedCount: <FormatNumber locale={this.state.locale} value={1000} />
52-
}} />
49+
task count 1000 formatted - <FormatMessage ref="formattedTask" locale={this.state.locale} path="task" variables={{count: 1000, formattedCount: Globalize(this.state.locale).formatNumber(1000)}} />
5350
<br/>
5451
like count 0 with offset:1 - <FormatMessage locale={this.state.locale} path="likeIncludingMe" variables={{count: 0}} />
5552
<br/>

index.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@ function capitalizeFirstLetter(string) {
66
return string.charAt(0).toUpperCase() + string.slice(1);
77
}
88

9-
function isPlainObject(value) {
10-
return value && typeof value === "object" &&
11-
!(value.constructor &&
12-
!value.constructor.prototype.hasOwnProperty("isPrototypeOf")) &&
13-
!React.isValidElement(value);
14-
}
15-
16-
function supportReactElements(value) {
17-
if (isPlainObject(value)) {
18-
return Object.keys(value).reduce(function(sum, i) {
19-
sum[i] = supportReactElements(value[i]);
20-
return sum;
21-
}, {});
22-
} else if (React.isValidElement(value)) {
23-
value = new ReactGlobalize[value.type.displayName](value._store.props).render()._store.props.children;
24-
}
25-
return value;
26-
}
27-
289
Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
2910
if (fn.indexOf("format") === 0) {
3011
var Fn = capitalizeFirstLetter(fn);
@@ -40,7 +21,7 @@ Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
4021
var instance = Globalize;
4122
var propArgs = argArray.map(function(element) {
4223
return componentProps[element.replace(/(\s\/\*|\*\/)/,"").trim()];
43-
}).map(supportReactElements);
24+
});
4425

4526
if (componentProps["locale"]) {
4627
instance = Globalize(componentProps["locale"]);

0 commit comments

Comments
 (0)