Skip to content
Merged
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 @@ -992,9 +992,11 @@ function returnsNonNode(
}
}
},
// Skip traversing all nested functions and their return statements
ArrowFunctionExpression: skipNestedFunctions(node),
FunctionExpression: skipNestedFunctions(node),
FunctionDeclaration: skipNestedFunctions(node),
ObjectMethod: node => node.skip(),
});

return !hasReturn || returnsNonNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

## Input

```javascript
// @compilationMode(infer)

import {Stringify} from 'shared-runtime';

function Test() {
const context = {
testFn() {
// if it is an arrow function its work
return () => 'test'; // it will break compile if returns an arrow fn
},
};

return <Stringify value={context} shouldInvokeFns={true} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [{}],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime"; // @compilationMode(infer)

import { Stringify } from "shared-runtime";

function Test() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const context = {
testFn() {
return _temp;
},
};

t0 = <Stringify value={context} shouldInvokeFns={true} />;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
function _temp() {
return "test";
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [{}],
};

```

### Eval output
(kind: ok) <div>{"value":{"testFn":{"kind":"Function","result":{"kind":"Function","result":"test"}}},"shouldInvokeFns":true}</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @compilationMode(infer)

import {Stringify} from 'shared-runtime';

function Test() {
const context = {
testFn() {
// if it is an arrow function its work
return () => 'test'; // it will break compile if returns an arrow fn
},
};

return <Stringify value={context} shouldInvokeFns={true} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Test,
params: [{}],
};
4 changes: 2 additions & 2 deletions fixtures/view-transition/src/components/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function Page({url, navigate}) {
}}>
{show ? 'A' : 'B'}
</button>
<ViewTransition>
<ViewTransition className="none">
<div>
{show ? (
<div>
Expand Down Expand Up @@ -92,7 +92,7 @@ export default function Page({url, navigate}) {
<div>!!</div>
</ViewTransition>
</Activity>
{show ? <Component /> : <p>&nbsp;</p>}
{show ? <Component /> : null}
</div>
</ViewTransition>
</div>
Expand Down
Loading
Loading