// Enable highlight updates to see re-renders// 1. Open React DevTools// 2. Click Settings (gear icon)// 3. Check "Highlight updates when components render"// 4. Watch colored borders appear on updates// Search for components// 1. Click in Components tab// 2. Press Cmd+F (Mac) or Ctrl+F (Windows)// 3. Type component name// 4. Navigate with Enter/Shift+Enter// View component source// 1. Select component in tree// 2. Right panel shows props, state, hooks// 3. Click "<>" icon to view source code// 4. Opens in Sources tab at component definition
DevTools Shortcuts: Cmd/Ctrl + F (search), Cmd/Ctrl + P (search by component name), Click
component in page to select in tree (requires "Inspect" feature enabled), Click eye icon to inspect DOM node,
Use filter input to narrow tree view.
2. Component Tree Inspector and Props Viewer
Inspector Feature
Information Shown
Interaction
Use Case
Props Panel
All props passed to component
View values, edit primitives
Debug incorrect prop values, test different prop combinations
State Panel
Component state values
View and edit state
Test different states, reproduce bugs, validate state logic
Hooks Panel
All hooks in component with values
View hook state, effects
Debug custom hooks, verify hook dependencies
Rendered By
Parent component that rendered this component
Click to navigate to parent
Understand component hierarchy and data flow
Owners
Component ownership chain
Shows entire owner hierarchy
Trace where props originated, debug context issues
Source Location
File and line number of component
Click to open in Sources tab
Quick navigation to component code
Example: Editing props and state in DevTools
// Original componentfunction Counter() { const [count, setCount] = useState(0); return <div>Count: {count}</div>;}// In React DevTools:// 1. Select Counter component// 2. In right panel, see "State" section// 3. Click on "count: 0" value// 4. Edit to different value (e.g., 100)// 5. Press Enter - component re-renders with new value// Editing props (parent component needed)function Parent() { return <Child name="Alice" age={25} />;}// In DevTools:// 1. Select Child component// 2. See "Props" section: name: "Alice", age: 25// 3. Edit primitive values directly// 4. Note: Complex objects/functions can't be edited
Example: Debugging hooks with DevTools
function UserProfile() { const [loading, setLoading] = useState(true); const [user, setUser] = useState(null); const [error, setError] = useState(null); useEffect(() => { fetchUser().then(setUser).catch(setError).finally(() => setLoading(false)); }, []); const memoizedUser = useMemo(() => formatUser(user), [user]); const handleClick = useCallback(() => console.log(user), [user]); // ...}// In DevTools, Hooks section shows:// State (0): true // loading// State (1): null // user// State (2): null // error// Effect // useEffect// Memo // useMemo// Callback // useCallback// You can:// - Edit state values directly// - See dependencies for useMemo/useCallback// - Track which effects ran// - Identify custom hooks by name
Example: Using "Rendered by" to trace component tree
// Component hierarchy<App> <Dashboard> <UserPanel> <UserAvatar src={user.avatar} /> </UserPanel> </Dashboard></App>// Select UserAvatar in DevTools// "Rendered by" section shows:// UserPanel → Dashboard → App// Click any parent to navigate// See full props chain:// - App passes user to Dashboard// - Dashboard passes user to UserPanel// - UserPanel passes user.avatar to UserAvatar
// Record interaction flow:// 1. Open React DevTools → Profiler// 2. Click Record// 3. Perform user actions (form submit, navigation, etc.)// 4. Click Stop// 5. Use timeline scrubber to navigate commits// Each commit shows:// - Which components rendered// - Why they rendered (props/state change)// - Render duration// - Component props/state at that moment// Navigate commits:// - Left/Right arrows to step through// - Click specific commit in timeline// - See exact component state at that point// - Compare before/after states
Example: Redux DevTools time-travel
// Install Redux DevTools Extension// Setup store with DevToolsimport { createStore } from 'redux';const store = createStore( reducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());// In Redux DevTools panel:// 1. See all dispatched actions in order// 2. Click any action to jump to that state// 3. Use slider to scrub through action history// 4. Toggle actions on/off to see impact// 5. Export/import state snapshots// 6. Replay actions at different speeds// DevTools features:// - Diff: See what changed in state// - Test: Generate test code from actions// - Export: Save state/action history as JSON// - Import: Load previous session// - Persist: Keep state across page reloads
import { Component } from 'react';import * as Sentry from '@sentry/react';class ErrorBoundary extends Component { constructor(props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error) { return { hasError: true, error }; } componentDidCatch(error, errorInfo) { // Log to console in development if (process.env.NODE_ENV === 'development') { console.error('Error caught by boundary:', error, errorInfo); } // Report to error tracking service Sentry.captureException(error, { contexts: { react: { componentStack: errorInfo.componentStack } } }); // Log to analytics analytics.track('error_boundary_triggered', { error: error.message, component: errorInfo.componentStack.split('\n')[1] }); } render() { if (this.state.hasError) { return this.props.fallback || ( <div role="alert"> <h2>Something went wrong</h2> <details style={{ whiteSpace: 'pre-wrap' }}> {this.state.error && this.state.error.toString()} </details> <button onClick={() => window.location.reload()}> Reload Page </button> </div> ); } return this.props.children; }}
Example: Source map configuration for production debugging
// Create React App - .env.productionGENERATE_SOURCEMAP=true// Upload source maps to Sentry// package.json{ "scripts": { "build": "react-scripts build", "sentry:upload": "sentry-cli releases files $npm_package_version upload-sourcemaps ./build" }}// Webpack config (for custom setup)module.exports = { devtool: 'source-map', // Generate source maps plugins: [ new SentryWebpackPlugin({ include: './build', ignoreFile: '.sentrycliignore', ignore: ['node_modules', 'webpack.config.js'], configFile: 'sentry.properties', release: process.env.REACT_APP_VERSION }) ]};// .sentryignorenode_modules/*.map// Only upload source maps, don't serve them publicly// Serve source maps only to authenticated users or keep them private// Configure error tracking to fetch maps from your servers
Production Debugging Best Practices: Always use error boundaries, upload source maps to error
tracking service, sanitize sensitive data before logging, add user context to errors, implement breadcrumbs for
error context, monitor error rates and trends, set up alerts for critical errors, test error tracking in
staging, use session replay for complex bugs, correlate errors with releases.