Skip to content

Commit a405810

Browse files
committed
[mcp] Prompt improvements for smarter tool composition (#33108)
Our runtime results are still bogus, but so far this tweak let's the llm use the tools a little more intelligently. example: --- ```js import React from 'react'; function App() { const [count, setCount] = React.useState(0); const [data, setData] = React.useState([]); React.useEffect(() => { const processData = () => { console.log("Processing data..."); const newData = []; for (let i = 0; i < 1000000000; i++) { newData.push({ id: i, value: Math.random() * count }); } return newData; }; const processedData = processData(); setData(processedData); }, [count]); return ( <div> <p>Count: {count}</p> <p>Data Length: {data.length}</p> <ul> {data.slice(0, 5).map((item) => ( <li key={item.id}>Item {item.id}: {item.value.toFixed(2)}</li> ))} </ul> </div> ); }; ``` why is this component slow? use the react tools to figure this out. > I'll analyze why this component is slow using the React tools. Let's first evaluate the performance of the original code. > [review-react-runtime ...] > > The performance measurement tool timed out, which is a strong indication of just how severe the performance issue is in this component. Let's now try to compile the code to see if React Compiler can identify any issues: > [compile...] > > Now I understand the issue. Let's analyze why this component > is extremely slow: > Main Performance Issues: > > Massive Data Processing: The component is trying to create an array with a billion (1,000,000,000) objects in the processData function. This is an enormous amount of data that will: > > Consume massive amounts of memory > Take an extremely long time to process > Likely crash the browser > > > Unnecessary Recalculation: The effect depends on [count], meaning every time the count changes, it will reprocess this enormous dataset. > Inefficient Data Handling: Even though only 5 items are displayed, the component processes a billion items. > > Let's fix these issues: > [compile...] > > Now let's check if our modified code performs better: > [review-react-runtime...] > > Excellent! The performance has dramatically improved. Now let's check the React documentation to make sure we're following the best practices: > [query-react-dev-docs...] (hit the maximum length conversation limit because i'm on a free plan) DiffTrain build for [26ecc98](26ecc98)
1 parent ee8cbec commit a405810

24 files changed

+87
-87
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-f0ca53d1-20250502
1+
19.2.0-native-fb-26ecc98a-20250502

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/eslint-plugin-react-hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "0.0.0-experimental-f0ca53d1-20250502",
4+
"version": "0.0.0-experimental-26ecc98a-20250502",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c797a136e3fee15e504bb8383f4979e3>>
10+
* @generated SignedSource<<dd23247ca2a8fc79fb927f144e466409>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
407+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<aa9b6c82e55872f976a41c050f6e1f16>>
10+
* @generated SignedSource<<4911436356c338f9fc2f5cfa3ecf6be0>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
206+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<aa9b6c82e55872f976a41c050f6e1f16>>
10+
* @generated SignedSource<<4911436356c338f9fc2f5cfa3ecf6be0>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
206+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d5848ef1081f9c346d96b5595a143637>>
10+
* @generated SignedSource<<361bc98a77546ba6b5d08836651cd6ba>>
1111
*/
1212

1313
/*
@@ -26650,11 +26650,11 @@ __DEV__ &&
2665026650
};
2665126651
(function () {
2665226652
var isomorphicReactPackageVersion = React.version;
26653-
if ("19.2.0-native-fb-f0ca53d1-20250502" !== isomorphicReactPackageVersion)
26653+
if ("19.2.0-native-fb-26ecc98a-20250502" !== isomorphicReactPackageVersion)
2665426654
throw Error(
2665526655
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2665626656
(isomorphicReactPackageVersion +
26657-
"\n - react-dom: 19.2.0-native-fb-f0ca53d1-20250502\nLearn more: https://react.dev/warnings/version-mismatch")
26657+
"\n - react-dom: 19.2.0-native-fb-26ecc98a-20250502\nLearn more: https://react.dev/warnings/version-mismatch")
2665826658
);
2665926659
})();
2666026660
("function" === typeof Map &&
@@ -26691,10 +26691,10 @@ __DEV__ &&
2669126691
!(function () {
2669226692
var internals = {
2669326693
bundleType: 1,
26694-
version: "19.2.0-native-fb-f0ca53d1-20250502",
26694+
version: "19.2.0-native-fb-26ecc98a-20250502",
2669526695
rendererPackageName: "react-dom",
2669626696
currentDispatcherRef: ReactSharedInternals,
26697-
reconcilerVersion: "19.2.0-native-fb-f0ca53d1-20250502"
26697+
reconcilerVersion: "19.2.0-native-fb-26ecc98a-20250502"
2669826698
};
2669926699
internals.overrideHookState = overrideHookState;
2670026700
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26838,5 +26838,5 @@ __DEV__ &&
2683826838
listenToAllSupportedEvents(container);
2683926839
return new ReactDOMHydrationRoot(initialChildren);
2684026840
};
26841-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
26841+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";
2684226842
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<245d2735c97f65c0ed9147f51b9d1381>>
10+
* @generated SignedSource<<c424a5ae1384bb4aec5837691e711f62>>
1111
*/
1212

1313
/*
@@ -16748,14 +16748,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1674816748
};
1674916749
var isomorphicReactPackageVersion$jscomp$inline_1904 = React.version;
1675016750
if (
16751-
"19.2.0-native-fb-f0ca53d1-20250502" !==
16751+
"19.2.0-native-fb-26ecc98a-20250502" !==
1675216752
isomorphicReactPackageVersion$jscomp$inline_1904
1675316753
)
1675416754
throw Error(
1675516755
formatProdErrorMessage(
1675616756
527,
1675716757
isomorphicReactPackageVersion$jscomp$inline_1904,
16758-
"19.2.0-native-fb-f0ca53d1-20250502"
16758+
"19.2.0-native-fb-26ecc98a-20250502"
1675916759
)
1676016760
);
1676116761
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16777,10 +16777,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1677716777
};
1677816778
var internals$jscomp$inline_2388 = {
1677916779
bundleType: 0,
16780-
version: "19.2.0-native-fb-f0ca53d1-20250502",
16780+
version: "19.2.0-native-fb-26ecc98a-20250502",
1678116781
rendererPackageName: "react-dom",
1678216782
currentDispatcherRef: ReactSharedInternals,
16783-
reconcilerVersion: "19.2.0-native-fb-f0ca53d1-20250502"
16783+
reconcilerVersion: "19.2.0-native-fb-26ecc98a-20250502"
1678416784
};
1678516785
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1678616786
var hook$jscomp$inline_2389 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16884,4 +16884,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1688416884
listenToAllSupportedEvents(container);
1688516885
return new ReactDOMHydrationRoot(initialChildren);
1688616886
};
16887-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
16887+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<e825b3b5479d45b99afd6a4444c72862>>
10+
* @generated SignedSource<<f66fa6039614d249bf24704ffbcc6da0>>
1111
*/
1212

1313
/*
@@ -17457,14 +17457,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1745717457
};
1745817458
var isomorphicReactPackageVersion$jscomp$inline_2007 = React.version;
1745917459
if (
17460-
"19.2.0-native-fb-f0ca53d1-20250502" !==
17460+
"19.2.0-native-fb-26ecc98a-20250502" !==
1746117461
isomorphicReactPackageVersion$jscomp$inline_2007
1746217462
)
1746317463
throw Error(
1746417464
formatProdErrorMessage(
1746517465
527,
1746617466
isomorphicReactPackageVersion$jscomp$inline_2007,
17467-
"19.2.0-native-fb-f0ca53d1-20250502"
17467+
"19.2.0-native-fb-26ecc98a-20250502"
1746817468
)
1746917469
);
1747017470
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17486,10 +17486,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1748617486
};
1748717487
var internals$jscomp$inline_2014 = {
1748817488
bundleType: 0,
17489-
version: "19.2.0-native-fb-f0ca53d1-20250502",
17489+
version: "19.2.0-native-fb-26ecc98a-20250502",
1749017490
rendererPackageName: "react-dom",
1749117491
currentDispatcherRef: ReactSharedInternals,
17492-
reconcilerVersion: "19.2.0-native-fb-f0ca53d1-20250502",
17492+
reconcilerVersion: "19.2.0-native-fb-26ecc98a-20250502",
1749317493
getLaneLabelMap: function () {
1749417494
for (
1749517495
var map = new Map(), lane = 1, index$305 = 0;
@@ -17608,4 +17608,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1760817608
listenToAllSupportedEvents(container);
1760917609
return new ReactDOMHydrationRoot(initialChildren);
1761017610
};
17611-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
17611+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a04832d4b206d42f8222902aae7a114b>>
10+
* @generated SignedSource<<278571ab231c4c458f9857ea08c76e38>>
1111
*/
1212

1313
/*
@@ -26711,11 +26711,11 @@ __DEV__ &&
2671126711
};
2671226712
(function () {
2671326713
var isomorphicReactPackageVersion = React.version;
26714-
if ("19.2.0-native-fb-f0ca53d1-20250502" !== isomorphicReactPackageVersion)
26714+
if ("19.2.0-native-fb-26ecc98a-20250502" !== isomorphicReactPackageVersion)
2671526715
throw Error(
2671626716
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2671726717
(isomorphicReactPackageVersion +
26718-
"\n - react-dom: 19.2.0-native-fb-f0ca53d1-20250502\nLearn more: https://react.dev/warnings/version-mismatch")
26718+
"\n - react-dom: 19.2.0-native-fb-26ecc98a-20250502\nLearn more: https://react.dev/warnings/version-mismatch")
2671926719
);
2672026720
})();
2672126721
("function" === typeof Map &&
@@ -26752,10 +26752,10 @@ __DEV__ &&
2675226752
!(function () {
2675326753
var internals = {
2675426754
bundleType: 1,
26755-
version: "19.2.0-native-fb-f0ca53d1-20250502",
26755+
version: "19.2.0-native-fb-26ecc98a-20250502",
2675626756
rendererPackageName: "react-dom",
2675726757
currentDispatcherRef: ReactSharedInternals,
26758-
reconcilerVersion: "19.2.0-native-fb-f0ca53d1-20250502"
26758+
reconcilerVersion: "19.2.0-native-fb-26ecc98a-20250502"
2675926759
};
2676026760
internals.overrideHookState = overrideHookState;
2676126761
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27215,7 +27215,7 @@ __DEV__ &&
2721527215
exports.useFormStatus = function () {
2721627216
return resolveDispatcher().useHostTransitionStatus();
2721727217
};
27218-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
27218+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";
2721927219
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2722027220
"function" ===
2722127221
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0640a81fad9f0bf95b0210b32baafdc2>>
10+
* @generated SignedSource<<f9afdcf5c775cbb68965dbba0476cc33>>
1111
*/
1212

1313
/*
@@ -16759,14 +16759,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1675916759
};
1676016760
var isomorphicReactPackageVersion$jscomp$inline_1905 = React.version;
1676116761
if (
16762-
"19.2.0-native-fb-f0ca53d1-20250502" !==
16762+
"19.2.0-native-fb-26ecc98a-20250502" !==
1676316763
isomorphicReactPackageVersion$jscomp$inline_1905
1676416764
)
1676516765
throw Error(
1676616766
formatProdErrorMessage(
1676716767
527,
1676816768
isomorphicReactPackageVersion$jscomp$inline_1905,
16769-
"19.2.0-native-fb-f0ca53d1-20250502"
16769+
"19.2.0-native-fb-26ecc98a-20250502"
1677016770
)
1677116771
);
1677216772
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16788,10 +16788,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1678816788
};
1678916789
var internals$jscomp$inline_2391 = {
1679016790
bundleType: 0,
16791-
version: "19.2.0-native-fb-f0ca53d1-20250502",
16791+
version: "19.2.0-native-fb-26ecc98a-20250502",
1679216792
rendererPackageName: "react-dom",
1679316793
currentDispatcherRef: ReactSharedInternals,
16794-
reconcilerVersion: "19.2.0-native-fb-f0ca53d1-20250502"
16794+
reconcilerVersion: "19.2.0-native-fb-26ecc98a-20250502"
1679516795
};
1679616796
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1679716797
var hook$jscomp$inline_2392 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17049,4 +17049,4 @@ exports.useFormState = function (action, initialState, permalink) {
1704917049
exports.useFormStatus = function () {
1705017050
return ReactSharedInternals.H.useHostTransitionStatus();
1705117051
};
17052-
exports.version = "19.2.0-native-fb-f0ca53d1-20250502";
17052+
exports.version = "19.2.0-native-fb-26ecc98a-20250502";

0 commit comments

Comments
 (0)