@@ -1430,6 +1430,72 @@ if (__EXPERIMENTAL__) {
14301430 }
14311431 ` ,
14321432 } ,
1433+ {
1434+ code : normalizeIndent `
1435+ // Valid because functions created with useEffectEvent can be called in useLayoutEffect.
1436+ function MyComponent({ theme }) {
1437+ const onClick = useEffectEvent(() => {
1438+ showNotification(theme);
1439+ });
1440+ useLayoutEffect(() => {
1441+ onClick();
1442+ });
1443+ React.useLayoutEffect(() => {
1444+ onClick();
1445+ });
1446+ }
1447+ ` ,
1448+ } ,
1449+ {
1450+ code : normalizeIndent `
1451+ // Valid because functions created with useEffectEvent can be called in useInsertionEffect.
1452+ function MyComponent({ theme }) {
1453+ const onClick = useEffectEvent(() => {
1454+ showNotification(theme);
1455+ });
1456+ useInsertionEffect(() => {
1457+ onClick();
1458+ });
1459+ React.useInsertionEffect(() => {
1460+ onClick();
1461+ });
1462+ }
1463+ ` ,
1464+ } ,
1465+ {
1466+ code : normalizeIndent `
1467+ // Valid because functions created with useEffectEvent can be passed by reference in useLayoutEffect
1468+ // and useInsertionEffect.
1469+ function MyComponent({ theme }) {
1470+ const onClick = useEffectEvent(() => {
1471+ showNotification(theme);
1472+ });
1473+ const onClick2 = useEffectEvent(() => {
1474+ debounce(onClick);
1475+ debounce(() => onClick());
1476+ debounce(() => { onClick() });
1477+ deboucne(() => debounce(onClick));
1478+ });
1479+ useLayoutEffect(() => {
1480+ let id = setInterval(() => onClick(), 100);
1481+ return () => clearInterval(onClick);
1482+ }, []);
1483+ React.useLayoutEffect(() => {
1484+ let id = setInterval(() => onClick(), 100);
1485+ return () => clearInterval(onClick);
1486+ }, []);
1487+ useInsertionEffect(() => {
1488+ let id = setInterval(() => onClick(), 100);
1489+ return () => clearInterval(onClick);
1490+ }, []);
1491+ React.useInsertionEffect(() => {
1492+ let id = setInterval(() => onClick(), 100);
1493+ return () => clearInterval(onClick);
1494+ }, []);
1495+ return null;
1496+ }
1497+ ` ,
1498+ } ,
14331499 ] ;
14341500 allTests . invalid = [
14351501 ...allTests . invalid ,
0 commit comments