Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,41 @@ function validateNoRefAccessInRenderImpl(
switch (instr.value.kind) {
case 'JsxExpression':
case 'JsxFragment': {
for (const operand of eachInstructionValueOperand(instr.value)) {
validateNoDirectRefValueAccess(errors, operand, env);
if (instr.value.kind === 'JsxExpression') {
if (instr.value.tag.kind === 'Identifier') {
validateNoDirectRefValueAccess(errors, instr.value.tag, env);
}
for (const attribute of instr.value.props) {
switch (attribute.kind) {
case 'JsxAttribute': {
if (attribute.name !== 'ref') {
validateNoDirectRefValueAccess(
errors,
attribute.place,
env,
);
}
break;
}
case 'JsxSpreadAttribute': {
validateNoDirectRefValueAccess(
errors,
attribute.argument,
env,
);
break;
}
}
}
if (instr.value.children != null) {
for (const child of instr.value.children) {
validateNoDirectRefValueAccess(errors, child, env);
}
}
} else {
for (const operand of eachInstructionValueOperand(instr.value)) {
validateNoDirectRefValueAccess(errors, operand, env);
}
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

## Input

```javascript
// @validateRefAccessDuringRender @compilationMode:"infer"
function TextArea(props) {
return <TextInput ref={props.ref} type="body" />;
}

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime"; // @validateRefAccessDuringRender @compilationMode:"infer"
function TextArea(props) {
const $ = _c(2);
let t0;
if ($[0] !== props.ref) {
t0 = <TextInput ref={props.ref} type="body" />;
$[0] = props.ref;
$[1] = t0;
} else {
t0 = $[1];
}
return t0;
}

```

### Eval output
(kind: exception) Fixture not implemented
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @validateRefAccessDuringRender @compilationMode:"infer"
function TextArea(props) {
return <TextInput ref={props.ref} type="body" />;
}