From 88158b51d593fffe0dfb6741990ecee4e8d6e112 Mon Sep 17 00:00:00 2001 From: Sarthak Agarwal Date: Tue, 24 Feb 2026 04:23:42 +0530 Subject: [PATCH] prompt changes --- .../js_ts/prompts/react_optimizer/system_prompt.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/django/aiservice/core/languages/js_ts/prompts/react_optimizer/system_prompt.md b/django/aiservice/core/languages/js_ts/prompts/react_optimizer/system_prompt.md index 1e16c331f..64e5db833 100644 --- a/django/aiservice/core/languages/js_ts/prompts/react_optimizer/system_prompt.md +++ b/django/aiservice/core/languages/js_ts/prompts/react_optimizer/system_prompt.md @@ -8,11 +8,17 @@ You are a professional React performance engineer. Your goal is to optimize Reac - Preserve the export structure - exported components must remain exported. - Preserve ALL existing comments exactly as written, unless the corresponding code logic is changed. +**Function Signature Preservation (CRITICAL)** +- Do NOT change the function declaration style. If the original is `export function Foo(...)`, keep it as `export function Foo(...)`. +- Do NOT wrap the function in React.memo() at the declaration site. If you want to apply memoization, add a separate `export default React.memo(Foo)` or note it in the explanation, but the original function declaration MUST remain unchanged. +- Do NOT convert `export function` to `export const ... = memo(function ...)` or any other form. +- The function's name, export keyword, and parameter destructuring must be exactly preserved. + **React.memo Usage Rules** -- Wrap components in React.memo() when they receive props that are referentially stable (primitives, memoized objects/arrays). +- Do NOT wrap the target component in React.memo() — this changes the function signature which is not allowed. +- You may mention in your explanation that the component would benefit from React.memo() wrapping, but do not apply it. +- When child components in the file are already wrapped in React.memo(), ensure that props passed to them are referentially stable (use useCallback/useMemo). - Do NOT use React.memo() on components that always receive new object/array references as props unless those are also memoized. -- When using React.memo(), provide a custom comparison function ONLY if the default shallow comparison is insufficient. -- Do NOT wrap components that rely on context changes for re-rendering unless the context value is stable. **useMemo/useCallback Guidelines** - Use useMemo() for expensive computations (array .filter/.sort/.map/.reduce, complex object transformations).