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
Copy file name to clipboardExpand all lines: docs/common/COMMON_ISSUES.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,6 +177,65 @@ See `note.tsx` for grep and translate examples.
177
177
178
178
See `space-setup.tsx` for an example of handling this with prompts and cache busting.
179
179
180
+
## JSX in Utility Files
181
+
182
+
### Issue: Cannot Export JSX Components from Utility Files
183
+
184
+
**Symptom**: When trying to create reusable JSX components in utility files (e.g., `lib/my-utils.tsx`), you get compilation errors like:
185
+
```
186
+
[ERROR] This JSX tag requires 'h' to be in scope, but it could not be found.
187
+
[ERROR] Module '"commontools"' has no exported member 'h'.
188
+
```
189
+
190
+
**Cause**: JSX compilation requires `h` to be in scope, which is only available within recipe contexts. Utility files can't import or use JSX because they're not recipes.
191
+
192
+
**Solution**: Share utility functions instead of JSX components:
193
+
194
+
**✅ DO THIS** - Export pure functions from utility files:
**❌ DON'T DO THIS** - Try to export JSX components from utilities:
227
+
```typescript
228
+
// lib/diff-utils.tsx
229
+
exportfunction DiffText({ from, to }) { // Won't compile!
230
+
return <div>{from} → {to}</div>; // Error: h not in scope
231
+
}
232
+
```
233
+
234
+
**Key Principles**:
235
+
- Utility files: Export pure functions, types, and non-JSX logic
236
+
- Recipe files: Use JSX and compose with utility functions
237
+
- Use `/// <cts-enable />` directive at the top of utility files
238
+
180
239
## Transaction Conflicts and Retry Storms
181
240
182
241
If you see `ConflictError` messages in console, this is normal - the system retries transactions automatically. These warnings don't indicate a problem unless they occur continuously (retry storm).
0 commit comments