# Event Handler Instances: `{() => handler(arg)}` Pattern Found 167 instances across the codebase. --- ## Workspaces / Shared Components ### `src/workspaces/components/MarkdownEditor.tsx` - Line 48: `onClick={() => setShowPreview(false)}` - Line 52: `onClick={() => setShowPreview(true)}` ### `src/workspaces/components/SearchInput.tsx` - Line 49: `onClick={() => handleSearch('')}` ### `src/workspaces/components/ErrorDialogs/CustomError.tsx` - Line 25: `onClick={() => onOpenChange(false)}` ### `src/workspaces/components/ErrorDialogs/ForbiddenDialog.tsx` - Line 27: `onClick={() => onOpenChange(false)}` ### `src/workspaces/components/ErrorDialogs/UnauthorizedDialog.tsx` - Line 29: `onClick={() => onOpenChange(false)}` ### `src/workspaces/components/ErrorDialogs/ServerError.tsx` - Line 25: `onClick={() => onOpenChange(false)}` ### `src/workspaces/components/DataTable/PaginationBar.tsx` - Line 83: `onClick={() => changePage(1)}` - Line 93: `onClick={() => changePage(currentPage - 1)}` - Line 103: `onClick={() => changePage(currentPage + 1)}` - Line 113: `onClick={() => changePage(pageCount)}` ### `src/workspaces/components/DataTable/DataTable.tsx` - Line 89: `onClick={() => sortBy(sortKey as Extract | undefined)}` ### `src/workspaces/components/ui/mode-toggle.tsx` - Line 16: `onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}` --- ## Editor App ### `src/apps/editor/app/src/EditorV2/index.tsx` - Line 73: `onCollapse={() => setLeftCollapsed(true)}` - Line 74: `onExpand={() => setLeftCollapsed(false)}` - Line 97: `onCollapse={() => setRightCollapsed(true)}` - Line 98: `onExpand={() => setRightCollapsed(false)}` ### `src/apps/editor/app/src/EditorV2/ScreenshotDialog.tsx` - Line 114: `onClick={() => setView('list')}` - Line 131: `onClick={() => setView('editor')}` ### `src/apps/editor/app/src/EditorV2/Header/index.tsx` - Line 110: `onClick={() => setDevice(d)}` - Line 134: `onClick={() => setDevice(d)}` ### `src/apps/editor/app/src/EditorV2/Header/GlobalCodeMenu.tsx` - Line 32: `onClick={() => openEditor('js')}` - Line 33: `onClick={() => openEditor('css')}` ### `src/apps/editor/app/src/EditorV2/Header/ElementSelector.tsx` - Line 59: `onClick={() => setIsOpen(false)}` ### `src/apps/editor/app/src/EditorV2/RightSidebar/ElementInfo.tsx` - Line 23: `setTimeout(() => setCopiedHierarchical(false), 2000)` - Line 31: `setTimeout(() => setCopiedClassBased(false), 2000)` ### `src/apps/editor/app/src/EditorV2/RightSidebar/Breadcrumb.tsx` - Line 60: `onClick={() => selectMember(index)}` - Line 100: `onClick={() => selectMember(index)}` ### `src/apps/editor/app/src/EditorV2/RightSidebar/fields/PropertyColor.tsx` - Line 29: `return () => clearInterval(interval)` ### `src/apps/editor/app/src/EditorV2/LeftSidebar/HierarchyTab.tsx` - Line 25: `onClick={() => onSelect(index)}` ### `src/apps/editor/app/src/EditorV2/LeftSidebar/ChangesTab.tsx` - Line 46: `onMouseEnter={() => handleMouseEnter(change)}` - Line 48: `onClick={() => selectByChange(change)}` ### `src/apps/editor/app/src/EditorV2/Preview/index.tsx` - Line 118: `onClick={() => setInteractive(!interactive)}` - Line 132: `onClick={() => setMoveAnywhere(!moveAnywhere)}` ### `src/apps/editor/app/src/Editor/CodeEditorWindow/index.tsx` - Line 31: `onClick={() => setIsFullscreen(false)}` - Line 33: `onClick={() => setIsFullscreen(true)}` ### `src/apps/editor/app/src/Editor/ContextMenu/index.tsx` - Line 20: `onClick={() => setIsContextOpen(false)}` - Line 26: `onClick={() => openEditor('html')}` ### `src/apps/editor/app/src/Editor/BottomToolbar/GlobalCode/index.tsx` - Line 22: `onClick={() => openEditor('js')}` - Line 27: `onClick={() => openEditor('css')}` ### `src/apps/editor/app/src/Editor/BottomToolbar/VariantSelector/index.tsx` - Line 44: `onClick={() => setIsOpen(true)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/VariantSelector/CreateNewVariant.tsx` - Line 23: `onClose={() => setIsOpen(false)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/QuerySelector/index.tsx` - Line 49: `onClick={() => setIsOpen(false)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/DeviceSelector/index.tsx` - Line 23: `onSelect={() => setDevice(device)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/MoveAnywhere/index.tsx` - Line 12: `onClick={() => setMoveAnywhere((curr) => !curr)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/InteractivitySelector/index.tsx` - Line 13: `onClick={() => setInteractive((curr) => !curr)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/Changes/ChangesList.tsx` - Line 26: `onMouseEnter={() => selectByChange(change)}` - Line 48: `onClick={() => removeChange(change)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/Screenshot/ScreenshotList.tsx` - Line 38: `onMouseEnter={() => setHovered(screenshot.id)}` - Line 39: `onMouseLeave={() => setHovered(null)}` - Line 56: `onClick={() => setEditing(null)}` - Line 64: `onClick={() => setEditing(screenshot.id)}` - Line 68: `onClick={() => setWantsToDelete(screenshot.id)}` - Line 75: `onConfirm={() => onDeleteConfirm(screenshot.id)}` - Line 76: `onClose={() => setWantsToDelete(null)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/Screenshot/Controls.tsx` - Line 87: `onClick={() => handleUpload(comment)}` ### `src/apps/editor/app/src/Editor/BottomToolbar/Screenshot/index.tsx` - Line 38: `onClick={() => setView('list')}` - Line 47: `onClick={() => setView('upload')}` ### `src/apps/editor/extension/src/Auth/SigninPage.tsx` - Line 18: `setTimeout(() => navigate('/'), 100)` ### `src/apps/editor/extension/src/Screens/ExperimentList/ExperimentVariantList/SearchFilter.tsx` - Line 22: `onClick={() => onSearchChange('')}` --- ## Dashboard App ### `src/apps/dashboard/hooks/use-toast.tsx` - Line 143: `const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id })` ### `src/apps/dashboard/Screens/AdminTools/TestExperiments/TestExperiments.tsx` - Line 38: `onClick={() => setShowDuplicateModal(true)}` - Line 48: `onClose={() => setShowDuplicateModal(false)}` ### `src/apps/dashboard/Screens/Dashboard/Monitor/TrendTable.tsx` - Line 99: `onToggle={() => toggleRow(`trend-${exp.id}`)}` - Line 114: `onClick={() => setCurrentPage(1)}` - Line 120: `onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}` - Line 128: `onClick={() => setCurrentPage((p) => Math.min(totalPages, p + 1))}` - Line 136: `onClick={() => setCurrentPage(totalPages)}` ### `src/apps/dashboard/Screens/Dashboard/Monitor/GroupedExperimentsTable.tsx` - Line 75: `onToggle={() => toggleRow(`grouped-${exp.id}`)}` - Line 91: `onClick={() => setCurrentPage(1)}` - Line 97: `onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}` - Line 105: `onClick={() => setCurrentPage((p) => Math.min(totalPages, p + 1))}` - Line 113: `onClick={() => setCurrentPage(totalPages)}` ### `src/apps/dashboard/Screens/Dashboard/Home/ExperimentsOverviewTableMobile.tsx` - Line 23: `onClick={() => sort('id')}` - Line 28: `onClick={() => sort('status')}` - Line 34: `onClick={() => sort('sessions')}` ### `src/apps/dashboard/Screens/Dashboard/Home/ConfirmDialogs.tsx` - Line 36: `onOpenChange={() => setDialogAction(null)}` ### `src/apps/dashboard/Screens/Dashboard/Home/RowActions.tsx` - Line 31: `onClick={() => navigate(`/experiments/${id}`)}` - Line 32: `onClick={() => setDialogAction('duplicate')}` - Line 34: `onClick={() => setDialogAction('archive')}` - Line 37: `onClick={() => setDialogAction('delete')}` ### `src/apps/dashboard/Screens/Dashboard/Clients/index.tsx` - Line 76: `onClick={() => setIsCreating(true)}` - Line 108: `onClick={() => setIsCreating(true)}` - Line 119: `onClick={() => setOrganization(value as number)}` - Line 146: `onClick={() => handleSaveEdit(item.id)}` - Line 163: `onClick={() => handleEditName(item.id, item.friendlyName ?? '')}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/Timeline.tsx` - Line 111: `onClick={() => setMobileOpen((v) => !v)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Library/ActionModals.tsx` - Line 37: `onCancel={() => setDialogAction(null)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Library/TopHeader.tsx` - Line 44: `onClick={() => setIsCreating(true)}` - Line 69: `onClick={() => setIsCreating(true)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Library/ActionsCell.tsx` - Line 29: `onClick={() => navigate(`/experiments/${id}`)}` - Line 30: `onClick={() => setDialogAction('duplicate')}` - Line 32: `onClick={() => setDialogAction('archive')}` - Line 35: `onClick={() => setDialogAction('delete')}` - Line 44: `onClose={() => setDialogAction(null)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Library/CreateExperimentModal.tsx` - Line 88: `onCancel={() => setIsCreating(false)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/Header.tsx` - Line 86: `onClick={() => setDialogAction('duplicate')}` - Line 89: `onClick={() => setDialogAction('archive')}` - Line 92: `onClick={() => setDialogAction('delete')}` - Line 199: `onCancel={() => setDialogAction(null)}` - Line 214: `onCancel={() => setDialogAction(null)}` - Line 232: `onCancel={() => setDialogAction(null)}` - Line 246: `onCancel={() => setDialogAction(null)}` ### `src/apps/dashboard/Screens/Dashboard/Settings/Billing/index.tsx` - Line 137: `onClick={() => createCheckoutSession(+price.id)}` ### `src/apps/dashboard/Screens/Dashboard/Settings/AgencyTeam/index.tsx` - Line 125: `onClick={() => setInviteDialogOpen(true)}` - Line 136: `onClick={() => setInviteDialogOpen(true)}` - Line 176: `onClick={() => resendInvite(item.email)}` - Line 217: `() => unblockUser(item.id)` - Line 230: `() => blockUser(item.id)` - Line 239: `onClick={() => resendInvite(item.email)}` - Line 247: `() => deleteUser(item.id)` - Line 303: `onClick={() => setInviteDialogOpen(false)}` - Line 315: `onCancel={() => setConfirmDialog({ ...confirmDialog, open: false })}` ### `src/apps/dashboard/Screens/Dashboard/Settings/OrganizationTeam/index.tsx` - Line 163: `onClick={() => setInviteDialogOpen(true)}` - Line 176: `onClick={() => setInviteDialogOpen(true)}` - Line 217: `onClick={() => resendInvite(item.email)}` - Line 259: `() => unblockUser(item.id)` - Line 272: `() => blockUser(item.id)` - Line 281: `onClick={() => resendInvite(item.email)}` - Line 289: `() => deleteUser(item.id)` - Line 361: `onClick={() => setInviteDialogOpen(false)}` - Line 373: `onCancel={() => setConfirmDialog({ ...confirmDialog, open: false })}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/VariantsConfig.tsx` - Line 57: `onClick={() => setShowAddVariant(true)}` - Line 167: `onClose={() => setEditingVariant(null)}` - Line 176: `onClose={() => setRenamingVariant(null)}` - Line 180: `onClose={() => setShowAddVariant(false)}` - Line 193: `onCancel={() => setDeletingVariant(null)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/CookieTargeting.tsx` - Line 50: `onClick={() => deleteCookieTargeting(item.id)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/DeviceTargeting.tsx` - Line 54: `onClick={() => deleteDeviceTargeting(device.id)}` - Line 65: `onClick={() => setIsAddOpen(true)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/GoalsConfig.tsx` - Line 85: `onCancel={() => setIsDialogOpen(false)}` - Line 97: `onCheckedChange={() => toggleGoal(tag.name)}` - Line 113: `onCheckedChange={() => toggleGoal(tag.name)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/UrlTargeting.tsx` - Line 95: `onClick={() => openEditDialog(item)}` - Line 98: `onClick={() => deleteUrlTargeting(item.id)}` - Line 119: `onCancel={() => setEditItem(null)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentSettings/EditWeightsModal.tsx` - Line 25: `useState(() => String(Math.round((currentWeight || 0) / 100)))` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentInfo/Description.tsx` - Line 44: `onClick={() => setIsEditing(true)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentStatistics/StatisticsTable.tsx` - Line 209: `onClick={() => setWantsToDeploy(item)}` - Line 227: `onCancel={() => setWantsToDeploy(null)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentInfo/Screenshots/ScreenshotItem.tsx` - Line 62: `onClick={() => setIsOpen(true)}` - Line 65: `onLoad={() => setImageLoaded(true)}` - Line 90: `onClick={() => setEditing(null)}` - Line 107: `onClick={() => setWantsToDelete(true)}` - Line 114: `onClose={() => setIsOpen(false)}` - Line 119: `onCancel={() => setWantsToDelete(false)}` ### `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentInfo/Screenshots/ScreenshotList.tsx` - Line 49: `onMouseEnter={() => setHovered(screenshot.id)}` - Line 49: `onMouseLeave={() => setHovered(null)}` ### `src/apps/dashboard/Screens/Dashboard/Websites/List/index.tsx` - Line 71: `onClick={() => setIsCreating(true)}` - Line 100: `onClick={() => setIsCreating(true)}` - Line 112: `onClick={() => setWebsite(value as number)}` - Line 167: `onClick={() => refreshPropertyTags(item)}` - Line 190: `onClick={() => recheckPermissions(item.ganPropertyId!)}` - Line 220: `onClick={() => handleDelete(value as number)}` ### `src/apps/dashboard/Screens/Dashboard/Websites/List/ServerContainerUrl.tsx` - Line 18: `setTimeout(() => setNewServerContainerUrl(null), 400)` - Line 45: `onClick={() => setNewServerContainerUrl(null)}` - Line 53: `onClick={() => setNewServerContainerUrl(website.serverContainerUrl || '')}` ### `src/apps/dashboard/Screens/Dashboard/Websites/List/ScriptsModal.tsx` - Line 18: `setTimeout(() => setCopiedText(null), 3000)` - Line 23: `onClick={() => setIsOpen(true)}` - Line 74: `onClick={() => setIsOpen(false)}` ### `src/apps/dashboard/Screens/Dashboard/Websites/GoogleAnalytics/GoogleAnalyticsScreen.tsx` - Line 91: `onClick={() => refresh(item.email)}` ### `src/apps/dashboard/Screens/Dashboard/DashboardLayout/index.tsx` - Line 17: `useGlobal('PAGE_TITLE', () => getPageTitle(location.pathname, MENU_LINKS))` ### `src/apps/dashboard/Screens/Dashboard/DashboardLayout/GlobalAlerts/index.tsx` - Line 14: `onClose={() => dismiss('Extension')}` - Line 15: `onClose={() => dismiss('Passkeys')}` ### `src/apps/dashboard/Screens/Dashboard/DashboardLayout/AppSidebar/Navigation.tsx` - Line 61: `onClick={() => setExpandedMenuItem(expandedMenuItem === item.key ? '' : item.key)}` ### `src/apps/dashboard/Screens/Dashboard/DashboardLayout/AppSidebar/AccountWebsiteSelectors.tsx` - Line 42: `onClick={() => setOpenPanel('account')}` - Line 55: `onClick={() => setOpenPanel('website')}` - Line 315: `onClick={() => chooseOptionValue(option.value as number)}` --- ## Summary by Pattern Type ### 1. Boolean State Setters (e.g., `setState(true/false)`) Most common pattern - 60+ instances ### 2. Value State Setters (e.g., `setState(someValue)`) ~40 instances ### 3. Handlers with Arguments (e.g., `handleClick(id)`) ~35 instances ### 4. Callbacks to null (e.g., `setItem(null)`) ~25 instances ### 5. Navigation (e.g., `navigate(path)`) ~5 instances ### 6. setTimeout callbacks ~5 instances --- ## High Priority (Inside loops/maps) These create N function instances per render: - `src/apps/editor/app/src/Editor/BottomToolbar/Screenshot/ScreenshotList.tsx:38-76` - `src/apps/editor/app/src/EditorV2/LeftSidebar/ChangesTab.tsx:46-48` - `src/apps/editor/app/src/EditorV2/RightSidebar/Breadcrumb.tsx:60,100` - `src/apps/editor/app/src/EditorV2/LeftSidebar/HierarchyTab.tsx:25` - `src/apps/dashboard/Screens/Dashboard/Experiments/Details/ExperimentInfo/Screenshots/ScreenshotList.tsx:49` - `src/apps/dashboard/Screens/Dashboard/Settings/AgencyTeam/index.tsx` (multiple in table rows) - `src/apps/dashboard/Screens/Dashboard/Settings/OrganizationTeam/index.tsx` (multiple in table rows) - `src/apps/dashboard/Screens/Dashboard/Websites/List/index.tsx` (multiple in table rows) - `src/apps/dashboard/Screens/Dashboard/Clients/index.tsx` (multiple in table rows)