feature: Support whitelisting mutable props for react-constant-elements (#5307)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// This is the same as the pure-expression-whitelist test, but 'FormattedMessage' is *not* whitelisted
|
||||
// so it should not be hoisted.
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="someMessage.foo"
|
||||
defaultMessage={
|
||||
"Some text, " +
|
||||
"and some more too. {someValue}"
|
||||
}
|
||||
description="A test message for babel."
|
||||
values={{
|
||||
someValue: "A value."
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// This is the same as the pure-expression-whitelist test, but 'FormattedMessage' is *not* whitelisted
|
||||
// so it should not be hoisted.
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return <FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
|
||||
someValue: "A value."
|
||||
}} />;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
|
||||
"plugins": [
|
||||
["transform-react-constant-elements", {"allowMutablePropsOnTags": ["FormattedNumber"]}],
|
||||
"syntax-jsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import Intl from 'react-intl';
|
||||
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<Intl.FormattedMessage
|
||||
id="someMessage.foo"
|
||||
defaultMessage={
|
||||
"Some text, " +
|
||||
"and some more too. {someValue}"
|
||||
}
|
||||
description="A test message for babel."
|
||||
values={{
|
||||
someValue: "A value."
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import Intl from 'react-intl';
|
||||
|
||||
var _ref = <Intl.FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
|
||||
someValue: "A value."
|
||||
}} />;
|
||||
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return _ref;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
|
||||
"plugins": [
|
||||
["transform-react-constant-elements", {"allowMutablePropsOnTags": ["FormattedMessage"]}],
|
||||
"syntax-jsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="someMessage.foo"
|
||||
defaultMessage={
|
||||
"Some text, " +
|
||||
"and some more too. {someValue}"
|
||||
}
|
||||
description="A test message for babel."
|
||||
values={{
|
||||
someValue: "A value."
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
var _ref = <FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
|
||||
someValue: "A value."
|
||||
}} />;
|
||||
|
||||
var Foo = React.createClass({
|
||||
render: function () {
|
||||
return _ref;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
|
||||
"plugins": [
|
||||
["transform-react-constant-elements", {"allowMutablePropsOnTags": ["FormattedMessage"]}],
|
||||
"syntax-jsx"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user