Common Issues - PatternFly 6 Frontend¶
This document covers frequently encountered problems and their solutions when developing with PatternFly 6 React components.
Introduction¶
PatternFly 6 development with Vite can present various challenges ranging from setup issues to component-specific problems. This guide focuses on frontend-specific issues and their solutions.
Related Files¶
- Setup Guide - Initial setup troubleshooting
- External References - Additional troubleshooting resources
Setup Issues¶
Node.js and npm Problems¶
Issue: Command not found errors¶
# Error messages
'node' is not recognized as an internal or external command
'npm' is not recognized as an internal or external command
Solutions:
- Verify Installation:
- Reinstall Node.js:
- Download from https://nodejs.org/
- Choose LTS version for stability
-
Restart terminal after installation
-
PATH Configuration:
# Windows: Add to PATH environment variable
C:\Program Files\nodejs\
# macOS/Linux: Add to shell profile
export PATH="/usr/local/bin/node:$PATH"
Issue: npm permission errors¶
Solutions:
- Use nvm (Recommended):
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install and use Node.js
nvm install node
nvm use node
- Fix npm permissions:
# Create global directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to PATH
export PATH=~/.npm-global/bin:$PATH
Project Setup Issues¶
Issue: Git clone failures¶
Solutions:
- Check Network Connection: Verify internet connectivity
- Use HTTPS instead of SSH:
- Check Repository URL: Verify the repository exists and URL is correct
Issue: npm install failures¶
Solutions:
- Clear npm cache:
- Delete node_modules and reinstall:
- Check npm registry:
- Install with legacy peer deps:
Development Server Issues¶
Issue: Port already in use¶
Solutions:
- Find and kill process:
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
# macOS/Linux
lsof -ti:3000 | xargs kill -9
- Use different port:
Issue: Development server not starting¶
Solutions:
- Reinstall frontend dependencies:
- Check Vite configuration:
- Clear Vite cache:
Import and Module Issues¶
PatternFly Component Import Errors¶
Issue: Module not found errors¶
Solutions:
- Install PatternFly packages:
- Check import syntax:
// Correct imports
import { Button, Card } from '@patternfly/react-core'
import { Table, Thead, Tbody } from '@patternfly/react-table'
import { UserIcon } from '@patternfly/react-icons'
- Verify package.json dependencies:
Issue: Charts module not found¶
Solutions:
- Install charts dependencies:
- Use correct import paths:
- Clear cache and reinstall:
Issue: Chatbot module not found¶
Solutions:
- Install chatbot package:
- Import CSS:
- Use correct import paths:
Styling Issues¶
CSS and Class Problems¶
Issue: PatternFly styles not applied¶
Solutions:
- Import PatternFly CSS:
- Check CSS import order:
// PatternFly CSS should be imported before custom CSS
import '@patternfly/react-core/dist/styles/base.css'
import './custom-styles.css'
- Verify webpack CSS handling:
Issue: Wrong PatternFly version classes¶
// Problem: Using old class names
<div className="pf-c-button"> // v4 class
<div className="pf-v5-c-button"> // v5 class
Solutions:
- Use PatternFly v6 classes:
- Update class references:
- Use PatternFly components instead:
Layout and Responsive Issues¶
Issue: Components not responsive¶
Solutions:
- Use PatternFly responsive utilities:
- Implement responsive patterns:
<div className="pf-v6-l-grid pf-v6-m-gutter">
<div className="pf-v6-l-grid__item pf-v6-m-12-col pf-v6-m-6-col-on-md">Content</div>
</div>
- Use container-based sizing:
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
useEffect(() => {
const updateDimensions = () => {
if (containerRef.current) {
const { width, height } = containerRef.current.getBoundingClientRect()
setDimensions({ width, height })
}
}
updateDimensions()
window.addEventListener('resize', updateDimensions)
return () => window.removeEventListener('resize', updateDimensions)
}, [])
PatternFly 6 Deprecated Components¶
Completely Deprecated in v6¶
These components are no longer supported and require migration:
Old Select Component¶
// ❌ Deprecated
import { Select, SelectOption } from '@patternfly/react-core/deprecated'
// ✅ Use new Select
import { Select, SelectOption } from '@patternfly/react-core'
Old Dropdown Component¶
// ❌ Deprecated
import { Dropdown, DropdownToggle } from '@patternfly/react-core/deprecated'
// ✅ Use new Dropdown
import { Dropdown, DropdownList, DropdownItem } from '@patternfly/react-core'
Old Wizard Component¶
// ❌ Deprecated
import { Wizard } from '@patternfly/react-core/deprecated'
// ✅ Use new Wizard
import { Wizard, WizardStep } from '@patternfly/react-core'
Old Table Component¶
// ❌ Deprecated non-composable table
// ✅ Use composable table
import { Table, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table'
Component API Changes¶
Button isDisabled → disabled¶
Text → Content¶
// ❌ Old
import { Text } from '@patternfly/react-core'
;<Text component="h1">Title</Text>
// ✅ New
import { Content } from '@patternfly/react-core'
;<Content component="h1">Title</Content>
PageHeader Removed¶
// ❌ Old
<PageHeader title="My Page" />
// ✅ New - Use PageSection with Title
<PageSection>
<Title headingLevel="h1">My Page</Title>
</PageSection>
Component-Specific Issues¶
Dropdown Clipping Issues¶
Issue: Dropdown menu gets clipped¶
Solutions:
- Use appendTo prop:
- Configure positioning:
Table Performance Issues¶
Issue: Slow rendering with large datasets¶
Solutions:
- Implement pagination:
import { Pagination } from '@patternfly/react-core'
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(20)
const paginatedData = data.slice((page - 1) * perPage, page * perPage)
- Use virtualization:
import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { Table, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';
const DraggableRow = ({ id, text, index, moveRow }) => {
// ... existing code ...
- Optimize re-renders:
Vite-Specific Issues¶
HMR (Hot Module Replacement) Not Working¶
Issue: Changes not reflecting in browser¶
Solutions:
- Clear Vite cache:
- Check Vite config:
- Use polling for WSL/Docker:
API Integration Issues¶
Issue: API calls failing¶
Solutions:
- Check proxy configuration:
- Use environment variables:
Frontend Build Issues¶
Build Failures¶
Issue: Vite build process fails¶
Solutions:
- Check for TypeScript errors:
- Verify all imports:
- Clear build output:
Issue: Bundle size too large¶
Solutions:
- Analyze Vite bundle:
# Build with analysis
cd frontend && npx vite build --mode analyze
# Or use rollup-plugin-visualizer
npm install --save-dev rollup-plugin-visualizer
- Implement code splitting:
// Vite handles dynamic imports automatically
const LazyComponent = React.lazy(() => import('./HeavyComponent'))
;<Suspense fallback={<Spinner />}>
<LazyComponent />
</Suspense>
- Optimize imports:
Browser Compatibility Issues¶
Cross-Browser Problems¶
Issue: Components not working in specific browsers¶
Solutions:
- Check Vite browser targets:
- Add polyfills if needed:
// vite.config.ts
import legacy from '@vitejs/plugin-legacy'
plugins: [
legacy({
targets: ['defaults', 'not IE 11'],
}),
]
- Test across browsers:
- Use browser dev tools
- Test on actual devices
- Use Playwright for automated testing
Frontend-Specific Issues¶
Module Resolution¶
Issue: PatternFly modules not found¶
Solutions:
- Install PatternFly packages:
- Verify package versions:
- Clean install if needed:
Debugging Strategies¶
Frontend Debugging Approach¶
- Browser Console: Check for React and PatternFly warnings
- React DevTools: Inspect component props and state
- Network Tab: Monitor API calls and asset loading
- TypeScript: Run
npm run type-checkfor type errors - Documentation: Reference this pf6-guide for best practices
Debug Tools¶
- React DevTools: Inspect component state and props
- Browser DevTools: Network, console, and element inspection
- Vite Inspector: Press
hin terminal for Vite shortcuts - Playwright UI: Run
npm run test:e2e:uifor visual debugging - Vitest UI: Run
npm run test:uifor test debugging
Getting Help¶
- GitHub Issues: Search and create issues with minimal reproduction
- Stack Overflow: Use
patternflytag for questions - Community Slack: Real-time help from community
- Documentation: Always check latest official documentation
Prevention Strategies¶
Best Practices¶
- Keep Dependencies Updated: Update PatternFly 6 packages together
- Use pf6-guide: Follow this guide as the source of truth for PatternFly practices
- Test Both Themes: Always test in light and dark themes
- Use Rem Units: Convert px to rem (divide by 16) for breakpoints
- Follow Token System: Use semantic design tokens, not hardcoded values
- Run Codemods: Use migration tools when upgrading
Code Quality¶
- Type Safety: Use TypeScript when possible
- Testing: Write unit tests for components
- Code Review: Review changes for PatternFly compliance
- Performance Monitoring: Track bundle size and performance metrics
Remember: When encountering issues, always check the official PatternFly documentation first, then search GitHub issues for similar problems. Provide specific error messages, code snippets, and version information when seeking help.