Files
supabase/apps/studio/components
Alaister Young eb0a91d82c fix(studio): memoise readReplicas in Destinations to break replication render loop
\`readReplicas\` was a fresh array reference every render (\`databases.filter(...)\`
without \`useMemo\`). The polling useEffect deps \`[isDatabasesSuccess, readReplicas]\`
were therefore unstable, the effect ran every render, and the
\`setStatusRefetchInterval\` write churn kept the parent re-rendering.

That alone wouldn't normally break — React bails out on same-value setState
— but it kept the Tooltip parent re-rendering in a tight loop, which trips
a latent bug in @radix-ui/react-slot 1.2.x: Slot's render uses plain
\`composeRefs(forwardedRef, childrenRef)\` instead of \`useComposedRefs\`, so
each render produces a new ref function. React replaces the ref each time,
calls oldFn(null) → newFn(node), which propagates to the Tooltip's
\`useState(setTrigger)\` ref and flips state null↔node forever until React
trips the max-update-depth guard.

Stable parent → stable Slot ref → no loop. Mirrors what
ReplicationDiagram.tsx already does for the same field.

Surfaces under TanStack Start because our route shells re-render more
frequently than Next's getLayout pipeline; the underlying Slot bug is
React-version-agnostic but the timing under TanStack tips this page over.
2026-05-08 16:27:48 +08:00
..

Writing components

Where to create your components

  • For components that declare the general structure and layout of a page:
    • /components/layouts/xxx
  • For components that are tightly coupled to a specific interface:
    • /components/interfaces/xxx
  • For components that are meant to be reusable across multiple pages:
    • /components/ui/xxx
  • Note: We're gradually moving files out of the to-be-cleaned folder into the respective folders as we refactor

Component structure

  • If a component has constants and utility methods that are tightly coupled to itself, keep them close to the component and enclose them in a folder with an index.tsx as an entry point
  • Otherwise it can just be a file on its own
  • For example:
    • components/ui
      - SampleComponentA
        - SampleComponentA.tsx
        - SampleComponentA.constants.ts
        - SampleComponentA.utils.ts
        - SampleComponentA.types.ts
        - index.ts
      - SampleComponentB.tsx
      

Template for building components


// Declare the prop types of your component
interface ComponentAProps {
  sampleProp: string
}

// Name your component accordingly
const ComponentA = ({ sampleProp }: ComponentAProps) => {
  return <div>ComponentA: {sampleProp}</div>
}

export default ComponentA