- Create LayoutPreviewPage component for full-screen layout previews - Add preview route /themes/:themeId/layouts/:layoutId/preview to App routing - Update theme components with preview links and improved navigation - Fix iframe sandbox error by adding allow-scripts permission - Enhance template renderer with layout metadata support - Replace PostCSS with regex-only CSS parsing for browser compatibility - Add comprehensive standards documentation for code quality - Clean up CSS slot indicators to be always visible with descriptions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.2 KiB
3.2 KiB
React 19 Implementation Standards
Current Status: NOT IMPLEMENTED
The codebase uses React 19.1.1 but implements ZERO React 19 features. This is a significant gap.
This might be OK if the features aren't needed, are complex or costly, or there is a better way that
doesn't violate react standard approaches.
Required React 19 Features to Implement
1. Actions for Form Handling
Replace manual form state management with React 19 Actions:
// ❌ CURRENT - Manual state management
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const handleSubmit = async (e) => {
setLoading(true);
try {
await submitForm(e);
} catch (err) {
setError(err);
} finally {
setLoading(false);
}
};
// ✅ REACT 19 - Actions
const [state, submitAction] = useActionState(async (prevState, formData) => {
// Action automatically handles loading/error states
return await submitForm(formData);
}, initialState);
2. useOptimistic for Theme Previews
Implement optimistic updates for theme switching:
// ✅ IMPLEMENT
function ThemePreview({ currentTheme }) {
const [optimisticTheme, setOptimisticTheme] = useOptimistic(
currentTheme,
(currentTheme, optimisticValue) => ({ ...currentTheme, ...optimisticValue })
);
const switchTheme = async (newTheme) => {
setOptimisticTheme(newTheme); // Immediate UI update
await saveTheme(newTheme); // Actual save
};
}
3. Modern Context Syntax
Replace Provider wrapper with direct Context rendering:
// ❌ OLD
<ThemeContext.Provider value={themeValue}>
<App />
</ThemeContext.Provider>
// ✅ REACT 19
<ThemeContext value={themeValue}>
<App />
</ThemeContext>
4. Error Boundaries with Actions
Implement error boundaries that work with Actions:
// ✅ IMPLEMENT
class ThemeErrorBoundary extends React.Component {
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
componentDidCatch(error, errorInfo) {
// Log to error reporting service
console.error('Theme loading error:', error, errorInfo);
}
}
Implementation Priority
HIGH PRIORITY
- Theme selection Actions - Replace manual form handling
- Error boundaries - Add proper error handling
- useOptimistic for theme previews - Better UX
MEDIUM PRIORITY
- Context syntax modernization - Update provider patterns
- Form Actions for theme creation - When that feature is added
- Server Actions integration - If backend is added
LOW PRIORITY
- Preloading optimization - Use React 19 preloading APIs
- Streaming SSR - If SSR is implemented
- Advanced concurrent features - As needed
Migration Strategy
- Start with theme selection Actions (highest impact)
- Add error boundaries for robustness
- Implement optimistic updates for better UX
- Gradually modernize Context usage
- Add advanced features as needed