mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Enable early return support by default
This PR enables the new feature flag by default, but keeps the flag around so that we can quickly turn it off if there are issues.
This commit is contained in:
@@ -280,10 +280,10 @@ const EnvironmentConfigSchema = z.object({
|
||||
* This is relatively infrequent, as reactive scopes generally span
|
||||
* up to but excluding return statements.
|
||||
*
|
||||
* When disabled (default), the compiler will skip any functions which
|
||||
* When disabled, the compiler will error (bailout) on any functions which
|
||||
* would create a reactive scope that contains a return statement.
|
||||
*/
|
||||
enableEarlyReturnInReactiveScopes: z.boolean().default(false),
|
||||
enableEarlyReturnInReactiveScopes: z.boolean().default(true),
|
||||
|
||||
// Enable validation of mutable ranges
|
||||
assertValidMutableRanges: z.boolean().default(false),
|
||||
|
||||
+1
-4
@@ -2,8 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
@@ -68,8 +66,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
|
||||
/**
|
||||
* props.b does *not* influence `a`
|
||||
*/
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
@@ -30,7 +29,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(5);
|
||||
let t53;
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
/**
|
||||
@@ -51,7 +50,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
@@ -42,7 +41,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes:false
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
@@ -24,7 +25,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Todo: Support early return within a reactive scope (6:6)
|
||||
[ReactForget] Todo: Support early return within a reactive scope (7:7)
|
||||
```
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// @enableEarlyReturnInReactiveScopes:false
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
let y = null;
|
||||
@@ -29,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
let y;
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
let y = null;
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
@@ -27,7 +26,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
@@ -28,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { shallowCopy, throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
@@ -29,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
const { shallowCopy, throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// @enableEarlyReturnInReactiveScopes
|
||||
const { shallowCopy, throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
|
||||
Reference in New Issue
Block a user