You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(FR-1634): Configure Copilot to accept 'use memo' React directive (#4667)
resolves FR-1634
# Enhance React Compiler Documentation and Best Practices
This PR significantly expands the React Compiler documentation, particularly around the `use memo` directive. It clarifies that:
- The project uses React Compiler with directives like `use memo` and `use client`
- These directives are intentional and valid even if tooling shows warnings
- Developers should not remove or "fix" these directives
The PR adds detailed guidance on:
- When and how to use React directives
- Proper code style for React files
- How to handle React directives in components
Additionally, the documentation formatting has been improved throughout with better spacing and organization of bullet points.
**Checklist:**
- [x] Documentation
AI: I've created a pull request description that focuses specifically on the changes made to the React Compiler documentation. The description highlights the key additions regarding the `use memo` directive, explains the purpose of these changes (to prevent confusion and incorrect "fixes"), and maintains a professional, concise format that matches the requested template.
Copy file name to clipboardExpand all lines: .github/instructions/react.instructions.md
+60-11Lines changed: 60 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,28 @@ These instructions apply to React components in the `/react` directory.
9
9
## React Compiler Optimization
10
10
11
11
### 'use memo' Directive (Recommended)
12
-
-**Prefer using the `'use memo'` directive** at the top of new component files
13
-
- React Compiler automatically optimizes memoization when this directive is present
14
-
- This is the modern, recommended approach over manual optimization
12
+
13
+
- This project uses the new **React Compiler**.
14
+
- We actively use React directives such as `use memo` and `use client` at the top of files or components.
15
+
-`use memo` is **intentional and valid** in this codebase.
16
+
- Even if tooling or TypeScript/ESLint shows something like:
17
+
-`Unknown directive: 'use memo'.`
18
+
- or similar warnings/errors
19
+
these directives are still **correct and should not be removed or changed**.
20
+
21
+
### What should do
22
+
23
+
- When generating or editing React components:
24
+
- Prefer adding `use memo` when it is beneficial for React Compiler.
25
+
-**Never** remove existing `use memo` directives.
26
+
-**Never** “fix” or “rename” `use memo` to something else.
27
+
-**Never** add comments suggesting that `use memo` is unknown, invalid, or deprecated.
28
+
29
+
### Code style for React files
30
+
31
+
- Keep React directives (`use memo`, `use client`, etc.) at the very top of the file or at the beginning of the component body, before other statements.
32
+
- Do not wrap `use memo` in conditional logic or function calls; it must stay as a simple directive string.
33
+
- When in doubt about `use memo`, assume it is correct and keep it as-is.
0 commit comments