mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
fbt:param does not allow jsxfragment children
This commit is contained in:
+2
-5
@@ -1366,11 +1366,8 @@ function codegenJsxFbtChildElement(
|
||||
| t.JSXFragment {
|
||||
const value = codegenPlace(cx, place);
|
||||
switch (value.type) {
|
||||
case "StringLiteral": {
|
||||
return createJsxExpressionContainer(place.loc, value);
|
||||
}
|
||||
case "JSXElement":
|
||||
case "JSXFragment": {
|
||||
// fbt:param only allows JSX element or expression container as children
|
||||
case "JSXElement": {
|
||||
return value;
|
||||
}
|
||||
default: {
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
return (
|
||||
<Foo
|
||||
value={
|
||||
<fbt desc="Description of the parameter">
|
||||
<fbt:param name="value">{<>{identity(props.text)}</>}</fbt:param>%
|
||||
</fbt>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const c_0 = $[0] !== props.text;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
t0 = fbt._("{value}%", [fbt._param("value", <>{identity(props.text)}</>)], {
|
||||
hk: "10F5Cc",
|
||||
});
|
||||
$[0] = props.text;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const c_2 = $[2] !== t0;
|
||||
let t1;
|
||||
if (c_2) {
|
||||
t1 = <Foo value={t0} />;
|
||||
$[2] = t0;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t1 = $[3];
|
||||
}
|
||||
return t1;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
return (
|
||||
<Foo
|
||||
value={
|
||||
<fbt desc="Description of the parameter">
|
||||
<fbt:param name="value">{<>{identity(props.text)}</>}</fbt:param>%
|
||||
</fbt>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -456,6 +456,7 @@ const skipFilter = new Set([
|
||||
"class-component-with-render-helper",
|
||||
"fbtparam-with-jsx-element-content",
|
||||
"fbtparam-text-must-use-expression-container",
|
||||
"fbtparam-with-jsx-fragment-value",
|
||||
]);
|
||||
|
||||
export default skipFilter;
|
||||
|
||||
Reference in New Issue
Block a user