Skip to content

Commit 0022e02

Browse files
committed
fix(devtools): rename Solid use* primitives to create* for React Compiler compat
The devtools packages are Solid but used React-style naming (useStyles, useTheme, useDevtoolsState, ...) for their custom primitives. When an app enables React Compiler, it matches the use* convention and transforms this Solid code as if it were React, breaking the panel. Rename every custom Solid primitive in @tanstack/devtools, devtools-ui, and devtools-a11y from use* to create*, and import Solid's useContext and @solid-primitives' useKeyDownList under non-use aliases (getContext, getKeyDownList). BREAKING(@tanstack/devtools-ui): exported useTheme is renamed to createTheme.
1 parent b1c1b20 commit 0022e02

45 files changed

Lines changed: 199 additions & 175 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@tanstack/devtools-ui': minor
3+
'@tanstack/devtools': patch
4+
'@tanstack/devtools-a11y': patch
5+
---
6+
7+
fix: rename Solid `use*` primitives to `create*` so React Compiler doesn't transform them
8+
9+
The devtools packages are written in Solid but used React-style naming (`useStyles`, `useTheme`, `useDevtoolsState`, …) for their custom primitives. When an app enables React Compiler, the compiler matches the `use*` naming convention and transforms/optimizes this Solid code as if it were React, breaking the panel (it is Solid JSX, not React).
10+
11+
All custom Solid primitives in `@tanstack/devtools`, `@tanstack/devtools-ui`, and `@tanstack/devtools-a11y` are renamed from `use*` to `create*`, and Solid's own `useContext` / `@solid-primitives` `useKeyDownList` are imported under non-`use` aliases (`getContext`, `getKeyDownList`).
12+
13+
Breaking for `@tanstack/devtools-ui`: the exported `useTheme` is renamed to `createTheme`.

‎packages/devtools-a11y/src/core/components/IssueCard.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { For, Show } from 'solid-js'
44
import { Button } from '@tanstack/devtools-ui'
5-
import { useStyles } from '../styles/styles'
5+
import { createStyles } from '../styles/styles'
66

77
// types
88
import type { A11yIssue, SeverityThreshold } from '../types/types'
@@ -17,7 +17,7 @@ interface A11yIssueCardProps {
1717

1818
export function A11yIssueCard(props: A11yIssueCardProps) {
1919
const selector = () => props.issue.nodes[0]?.selector || 'unknown'
20-
const styles = useStyles()
20+
const styles = createStyles()
2121

2222
return (
2323
<div

‎packages/devtools-a11y/src/core/components/IssueList.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @jsxImportSource solid-js */
22

33
import { For, Show } from 'solid-js'
4-
import { useAllyContext } from '../contexts/allyContext'
4+
import { createAllyContext } from '../contexts/allyContext'
55
import {
66
SEVERITY_LABELS,
77
clearHighlights,
@@ -10,7 +10,7 @@ import {
1010
scrollToElement,
1111
} from '../utils/ui.utils'
1212
import { IMPACTS } from '../utils/ally-audit.utils'
13-
import { useStyles } from '../styles/styles'
13+
import { createStyles } from '../styles/styles'
1414
import { A11yIssueCard } from './IssueCard'
1515

1616
// types
@@ -24,8 +24,8 @@ export function A11yIssueList(props: A11yIssueListProps) {
2424
const [selectedIssueId, setSelectedIssueId] = props.selectedIssueSignal
2525

2626
// hooks
27-
const styles = useStyles()
28-
const ally = useAllyContext()
27+
const styles = createStyles()
28+
const ally = createAllyContext()
2929

3030
// handlers
3131
const handleIssueClick = (issueId: string) => {

‎packages/devtools-a11y/src/core/components/Settings.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { For, Show, createMemo, createSignal } from 'solid-js'
44
import { Button, Input, Select } from '@tanstack/devtools-ui'
55
import { getAvailableRules } from '../utils/ally-audit.utils'
6-
import { useAllyContext } from '../contexts/allyContext'
7-
import { CATEGORIES, CATEGORY_LABELS, useStyles } from '../styles/styles'
6+
import { createAllyContext } from '../contexts/allyContext'
7+
import { CATEGORIES, CATEGORY_LABELS, createStyles } from '../styles/styles'
88

99
// types
1010
import type {
@@ -18,8 +18,8 @@ interface A11ySettingsOverlayProps {
1818
}
1919

2020
export function A11ySettingsOverlay(props: A11ySettingsOverlayProps) {
21-
const { config, setConfig } = useAllyContext()
22-
const styles = useStyles()
21+
const { config, setConfig } = createAllyContext()
22+
const styles = createStyles()
2323

2424
const disabledRulesSet = createMemo(() => new Set(config.disabledRules))
2525
const availableRules = createMemo(() => getAvailableRules())

‎packages/devtools-a11y/src/core/components/Shell.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
import { Match, Show, Switch, createMemo, createSignal } from 'solid-js'
44
import { Button, Header, MainPanel } from '@tanstack/devtools-ui'
5-
import { useAllyContext } from '../contexts/allyContext'
5+
import { createAllyContext } from '../contexts/allyContext'
66
import { RULE_SET_LABELS, SEVERITY_LABELS } from '../utils/ui.utils'
7-
import { useStyles } from '../styles/styles'
7+
import { createStyles } from '../styles/styles'
88
import { A11yIssueList } from './IssueList'
99
import { A11ySettingsOverlay } from './Settings'
1010

1111
export function Shell() {
12-
const styles = useStyles()
12+
const styles = createStyles()
1313

1414
// ally context
1515
const { filteredIssues, allyResult, config, setConfig, triggerAllyScan } =
16-
useAllyContext()
16+
createAllyContext()
1717

1818
// ui state
1919
const selectedIssueSignal = createSignal<string>('')

‎packages/devtools-a11y/src/core/contexts/allyContext.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
createEffect,
66
createMemo,
77
createSignal,
8-
useContext,
8+
useContext as getContext,
99
} from 'solid-js'
1010
import { createStore } from 'solid-js/store'
1111
import { filterIssuesAboveThreshold, runAudit } from '../utils/ally-audit.utils'
@@ -24,7 +24,7 @@ import type { ParentComponent } from 'solid-js'
2424
// context state
2525
//
2626

27-
function useAllyValue() {
27+
function createAllyValue() {
2828
const [config, setConfig] =
2929
createStore<Required<A11yPluginOptions>>(mergeConfig())
3030

@@ -89,7 +89,7 @@ function useAllyValue() {
8989
}
9090
}
9191

92-
type ContextType = ReturnType<typeof useAllyValue>
92+
type ContextType = ReturnType<typeof createAllyValue>
9393

9494
//
9595
// context
@@ -100,18 +100,18 @@ const AllyContext = createContext<ContextType | null>(null)
100100
type AllyProviderProps = {}
101101

102102
export const AllyProvider: ParentComponent<AllyProviderProps> = (props) => {
103-
const value = useAllyValue()
103+
const value = createAllyValue()
104104

105105
return (
106106
<AllyContext.Provider value={value}>{props.children}</AllyContext.Provider>
107107
)
108108
}
109109

110-
export function useAllyContext() {
111-
const context = useContext(AllyContext)
110+
export function createAllyContext() {
111+
const context = getContext(AllyContext)
112112

113113
if (context === null) {
114-
throw new Error('useAllyContext must be used within an AllyProvider')
114+
throw new Error('createAllyContext must be used within an AllyProvider')
115115
}
116116

117117
return context

‎packages/devtools-a11y/src/core/styles/styles.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as goober from 'goober'
2-
import { useTheme } from '@tanstack/devtools-ui'
2+
import { createTheme } from '@tanstack/devtools-ui'
33
import { createMemo } from 'solid-js'
44

55
import type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui'
@@ -548,8 +548,8 @@ function createA11yPanelStyles(theme: TanStackDevtoolsTheme) {
548548
}
549549
}
550550

551-
export function useStyles() {
552-
const { theme } = useTheme()
551+
export function createStyles() {
552+
const { theme } = createTheme()
553553
const styles = createMemo(() => createA11yPanelStyles(theme()))
554554

555555
return styles

‎packages/devtools-ui/src/components/button.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createMemo } from 'solid-js'
22
import clsx from 'clsx'
3-
import { useStyles } from '../styles/use-styles'
3+
import { createStyles } from '../styles/use-styles'
44

55
// types
66
import type { JSX } from 'solid-js'
@@ -20,7 +20,7 @@ type ButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
2020
className?: string
2121
}
2222
export function Button(props: ButtonProps) {
23-
const styles = useStyles()
23+
const styles = createStyles()
2424

2525
const classes = createMemo(() => {
2626
const variant = props.variant || 'primary'

‎packages/devtools-ui/src/components/checkbox.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSignal } from 'solid-js'
2-
import { useStyles } from '../styles/use-styles'
2+
import { createStyles } from '../styles/use-styles'
33

44
interface CheckboxProps {
55
label?: string
@@ -9,7 +9,7 @@ interface CheckboxProps {
99
}
1010

1111
export function Checkbox(props: CheckboxProps) {
12-
const styles = useStyles()
12+
const styles = createStyles()
1313
const [isChecked, setIsChecked] = createSignal(props.checked || false)
1414

1515
const handleChange = (e: Event) => {

‎packages/devtools-ui/src/components/header.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import clsx from 'clsx'
2-
import { useStyles } from '../styles/use-styles'
2+
import { createStyles } from '../styles/use-styles'
33
import type { JSX } from 'solid-js/jsx-runtime'
44

55
export function Header({
66
children,
77
class: className,
88
...rest
99
}: JSX.IntrinsicElements['header']) {
10-
const styles = useStyles()
10+
const styles = createStyles()
1111
return (
1212
<header
1313
class={clsx(styles().header.row, 'tsqd-header', className)}
@@ -30,7 +30,7 @@ export function HeaderLogo({
3030
}
3131
onClick?: JSX.EventHandler<HTMLButtonElement, MouseEvent>
3232
}) {
33-
const styles = useStyles()
33+
const styles = createStyles()
3434
return (
3535
<div class={styles().header.logoAndToggleContainer}>
3636
<button class={clsx(styles().header.logo)} onClick={onClick}>

0 commit comments

Comments
 (0)