Use a Component Dependency Graph Before Changing Shared UI

Kyle · · 23 min read
Component dependency graph for assessing shared UI changes

A shared Button change can look harmless until it shifts checkout, auth, and dense table actions. A component dependency graph shows the callers, wrappers, and routes that a quick search leaves buried.

What matters is evidence before the diff: inspect the local graph, open real call sites, and separate import count from actual user impact. Don’t let an AI assistant guess past missing context.

Start with the questions that prevent rework:

  • Which wrappers hide the shared component’s real consumers?
  • Which routes expose risky prop combinations and layout constraints?
  • Which focus, loading, and icon-only states need verification?

Change shared UI with fewer surprises.

Why Shared UI Changes Feel Riskier Than They Look

You change a shared Button, Card, or form field, the diff is maybe 20 lines, and then someone asks the real question: where else does this show up?

That’s when the room gets quiet.

In a larger frontend codebase, shared UI changes get risky fast because the code lies by omission. You see one component. The product sees ten screens, three wrappers, two teams, and one checkout flow nobody wants to break on a Thursday afternoon.

The usual pain points are familiar:

  • direct callers are easy enough to find, until half the app imports a wrapper instead
  • barrel exports and aliases blur the real path
  • tribal knowledge is stale by the second sprint
  • multi-package imports hide cross-team dependencies
  • everyone wants speed, nobody wants visible regressions

This is also why shared UI changes get political. One team owns the component, but a lot of other teams depend on it. So every “small” edit becomes a negotiation about risk, not just code.

We prefer to replace memory with evidence. Before touching shared UI, we want to know who calls it, what sits on top of it, what it relies on, and which user-facing surfaces are likely to move if we change it.

That’s where a component dependency graph helps. It turns a black box into a network you can inspect before you edit anything. Not perfect truth. Useful truth.

What a Component Dependency Graph Shows, and What It Does Not

A component dependency graph is just a map of structural relationships in your codebase. Nodes can be components, files, routes, hooks, modules, registries, or screens. Edges show relationships such as imports, composition, calls, registrations, or usage chains.

For shared UI work, four views matter most:

  • direct callers of the shared component
  • transitive callers that lead up to real screens or routes
  • downstream dependencies the component itself relies on
  • central nodes that many parts of the app depend on

That last one matters more than people admit. A component can look harmless in isolation and still be a bad place to make a casual change because too much of the app leans on it.

This is the core of ui change blast radius analysis. You’re not asking “where is Button imported?” You’re asking “if Button changes, what paths through the product are structurally exposed?”

There’s a difference between direct and indirect usage, and this is where weak analysis falls apart. Direct usage is a file importing Button. Indirect usage is a screen importing PrimaryButton, which wraps Button, exported through index.ts, re-exported by a design system package, then rendered inside a modal flow.

A good graph helps you see through that indirection.

It does not solve everything. A graph can prove structural relationships. It cannot promise runtime coverage, visual correctness, state-specific behavior, or accessibility outcomes by itself.

Treat the graph as a planning tool, not a permission slip.

Why Static Analysis Is the Right First Pass for Shared UI

If you need frontend component impact analysis before making a change, static analysis is usually the right first pass.

It works before the edit exists. It doesn’t need a perfect test suite. It can scan a large repo quickly. And it often finds relationships nobody bothered to document because the code already contains the clues.

In frontend systems, those clues are all over the place:

  • imports and re-exports
  • route registration
  • modal or popup registries
  • component composition chains
  • shared hooks
  • context providers and consumers

Static analysis also has the right trust model when it’s done well. The goal is not “find every imaginable edge.” That gets noisy fast. The goal is to surface relationships developers can trust enough to guide the next check in source.

Manual search still matters. We use it constantly. grep, IDE references, and search across packages are good tools. They’re just not enough on their own.

Why?

Because search tells you where a symbol appears. It usually does not give you a connected view of upstream and downstream impact. It also struggles when the dependency is hidden behind wrappers, registries, or alias paths.

Human memory is faster than any tool until it’s wrong. In a multi-module repo, it’s wrong more often than people think.

There’s solid support for this approach. Static graph detection in frontend projects has been shown to work well when it stays close to provable relationships. In one evaluated React.js study, a component-relationship detection algorithm scored an average F1 of 0.95 against a manually constructed dependency graph. That is evidence that source-derived graphs can be accurate enough to guide investigation—but not proof that every relationship in a dynamic application is captured.

Production teams building dependency maps have landed on the same principle: don’t overstate what static analysis can’t prove. That restraint is what makes the graph useful instead of theatrical.

Find Shared Component Callers Before You Edit

Before you change shared UI, find the callers. Not just the imports. The callers.

Do it in layers.

Map the dependency chain

  1. Direct imports

    Find direct imports of the target component.

  2. Wrappers

    Find wrappers that re-export or customize it.

  3. Feature consumers

    Find feature components that consume those wrappers.

  4. Routes and flows

    Trace upward into routes, screens, and flows.

That last step is where the real answer usually lives.

React makes this harder than it looks. The common sources of indirection are predictable:

  • barrel exports and index.ts files
  • alias imports from design system packages
  • children-based composition where the target never appears in obvious JSX
  • context consumers that change behavior without changing the rendered tag
  • shared hooks that alter interaction or state handling behind the scenes

A practical triage method helps. We’d group callers by product area or screen, then flag anything involved in critical actions:

  • auth
  • checkout or payment
  • destructive actions
  • dense data tables
  • modal confirmations

Also note which callers are one-off and which represent reusable patterns. If ten screens use the same wrapper, that wrapper matters more than ten separate imports.

Your verification steps should be boring and disciplined:

  • open the top direct callers in source
  • trace at least one level upward into the screen that renders them
  • record prop combinations, states, and layout constraints
  • note anything unusual, like icon-only buttons or table row actions squeezed into tight width

This is shared component callers analysis, not import counting. Import count is often a bad proxy for risk.

A Practical Workflow for Frontend Component Impact Analysis

You don’t need a giant diagram of the whole app. In fact, that usually makes things worse. Past a certain size, the graph becomes wallpaper.

Use a local subgraph around the component you want to change.

Here’s the workflow we’d use for a refactor, bug fix, or design system update:

  1. Define the exact change.

    • API
    • layout
    • semantics
    • interaction
    • styling
  2. Generate or inspect the local subgraph. Focus on the target component, its direct callers, wrappers, and immediate dependencies.

  3. Collect direct and transitive callers. Stop when you hit meaningful user-facing screens, not every file in the repo.

  4. Group callers. Group by wrapper, feature, route, or package so patterns emerge.

  5. Inspect source for the high-risk callers. Read the actual code. Don’t let the graph do all the thinking.

  6. Classify likely impact.

    • visual only
    • API break risk
    • interaction risk
    • accessibility risk
    • token or theme spread
  7. Plan tests and visual checks before coding.

This reduces rework in PR review because you surface likely blast radius before the change exists. Most code review tools catch trouble after the edit is already in flight. That’s backwards.

Once you’ve mapped the impact, make a call:

  • Patch in place if behavior and visuals remain compatible across known callers.
  • Add a prop or variant if only some callers can safely adopt the new behavior.
  • Create a new component if the old contract needs to stay stable while migration happens.

That decision is usually obvious once you’ve traced real callers. Before that, teams tend to argue from intuition.

ChoiceUse when
Patch in placeBehavior and visuals remain compatible across known callers.
Add a prop or variantOnly some callers can safely adopt the new behavior.
Create a new componentThe old contract needs to stay stable while migration happens.

What Needs Separate Evidence Beyond the Graph

A component dependency graph is necessary for safe shared UI work. It is not sufficient.

The first gap is props. React props can hide more than they reveal.

  • prop spreading can pass behavior you won’t see at a glance
  • fallback logic changes real runtime behavior
  • the same component may show up with wildly different prop combinations across screens

If you don’t inspect actual call sites, you’ll miss the cases that matter.

Dynamic composition is another blind spot. Structural mapping won’t fully capture:

  • conditional rendering
  • lazy-loaded features
  • feature flags
  • CMS-driven sections
  • portals and modal managers
  • render props or function children

Then there’s CSS. This is where people get confident too early.

A Button style change may be local. A token change often isn’t. Change spacing, color, or focus ring tokens and you may affect many components that never import Button directly. Cascade and specificity can also create side effects outside the direct caller set. Theme providers, dark mode, responsive breakpoints, and container constraints all change the visual result.

The graph also can’t infer visual or accessibility safety. It won’t tell you if focus order now feels wrong, keyboard behavior broke in a dialog, accessible names disappeared on icon-only controls, or contrast dipped below an acceptable threshold in dark mode.

Check these separately:

  • focus visibility
  • keyboard navigation
  • accessible names
  • contrast
  • loading and disabled states
  • reduced motion or animated transitions

Honest limits build trust. Tool hype does the opposite.

React Component Usage Mapping Patterns That Change the Blast Radius

Some patterns distort react component usage mapping enough that you need to call them out early.

Wrapper inflation

One import path can hide a lot of real usage. PrimaryButton, DialogActionButton, SubmitButton, and IconButton may all sit on the same primitive. If you only count direct imports of Button, your blast radius estimate is already wrong.

Barrel export noise

Barrel exports make usage look flatter than it is. Forty files importing from one package entrypoint doesn’t mean forty equal risks. You still need the underlying dependency path.

Hooks and context coupling

A shared component can look local while its behavior depends on app-wide provider logic. Changing a component that consumes auth state, theme state, or form context is often riskier than its import graph suggests.

Route-level mapping

The practical question isn’t only who imports this component. It’s which user-facing surfaces contain it. Teams ship bugs on screens, not in import graphs.

Dead or legacy variants

Old wrappers and unreachable exports distort risk. A graph can help identify branches that no longer reach live screens. Don’t let dead code dominate your estimate.

Cycles and central nodes

Cycles and oddly central nodes are architecture smells. If a tiny primitive now sits in the middle of a tangled cluster, treat any edit there with extra care.

This is why safe design system updates are rarely about a single file. One primitive can sit under wrappers, themes, providers, and feature-specific shells that multiply the blast radius.

Illustrative Example: Planning a Safe Design System Update to Button

This is an illustrative example, not a claim about any specific codebase.

Say you want to update Button spacing, icon alignment, focus styling, and aria handling.

Start with structure.

  • find direct imports of Button
  • find wrappers like PrimaryButton, IconButton, SubmitButton, and dialog action buttons
  • trace those wrappers into screens, forms, and modal flows
  • inspect prop patterns such as icon-only, loading, destructive, full-width, and compact table actions
  • check whether the change touches shared tokens or only Button-local styles

A simple planning note might look like this:

Target: Button
Direct callers: 14
Wrappers: PrimaryButton, IconButton, SubmitButton, DialogActionButton
High-risk surfaces: auth form, checkout modal, destructive confirm dialog, row actions in data table
Token impact: focus ring token shared elsewhere
Unknowns: icon-only accessible names, compact layout overflow

Then verify what the graph can’t prove.

  • open affected screens
  • test narrow and wide layouts
  • test keyboard navigation and focus visibility
  • confirm icon-only buttons still have accessible names
  • review snapshots or visual diffs if you have them

At that point, the implementation choice usually clears up.

If the spacing and focus updates are visually compatible, patch in place.
If only some callers can tolerate the new alignment, gate it behind a prop.
If part of the app depends on the old behavior staying stable, create a new variant and migrate in phases.

Small UI edits don’t fail because the code change was big. They fail because the evidence was thin.

Component dependency graph for planning a safe design system button update

Tooling Options for a Graph You Can Trust

Teams usually answer this problem in four ways:

  • manual IDE search
  • repo-wide static analysis and dependency graphs
  • hand-maintained architecture diagrams
  • runtime instrumentation for narrow behaviors

Each has a place.

Manual search is easy to start and still worth doing. It’s weak at showing connected impact across wrappers, screens, and packages.

Hand-maintained diagrams look tidy until they drift. If they aren’t regenerated from code, they go stale. Fast.

Static graphs are strong when you want provable structural relationships. Some teams build them directly from AST and file-structure analysis so nodes and edges come from the codebase rather than from someone’s memory. That approach works well for caller mapping and blast radius planning because it starts from source, not assumptions.

Runtime data helps with behavior and actual execution paths, but it’s not a replacement for source-level dependency mapping. It answers a different question.

For AI-assisted teams, Pharaoh is one practical option. Pharaoh maps repositories into a knowledge graph so MCP-compatible coding assistants can query callers, dependencies, blast radius, existing code, and dead code before changes. The map refreshes on every push, supports TypeScript and Python repos, and works across multiple repos, which matters when shared UI doesn’t live in one package anymore. If you’re using Claude Code, Cursor, or Codex on a larger codebase, that kind of structural context is the difference between a useful assistant and an expensive guesser.

The best tool is the one that gives you trustworthy structural evidence and still pushes you back into the source when needed.

Prompts and Verification Steps You Can Use Today

If you’re working with an AI coding assistant, ask for evidence, not confidence.

Useful prompts:

  • List all direct and transitive callers of this shared component.
  • Group callers by route, screen, or package.
  • Show wrappers and re-export paths that hide real usage.
  • Identify related CSS, theme, or token dependencies.
  • Point out dead variants or unreachable exports that should not count toward the live blast radius.
  • Summarize likely risk areas and tie each one to the source files that support it.

Then verify the output like a skeptical reviewer.

  • confirm the highest-risk callers in source
  • inspect the prop combinations actually used
  • verify whether token changes expand the blast radius beyond the component itself
  • write down assumptions the graph could not prove

A simple pre-change checklist helps keep this disciplined:

  • target component
  • direct callers
  • transitive callers
  • screens to verify
  • visual states to check
  • accessibility states to check
  • rollout choice: patch, prop, or new variant

If you want help on the linting and testing side, our open source AI Code Quality Framework covers that part. The graph answers structure. Your checks still need to answer behavior.

Common Mistakes That Turn a Small UI Edit Into a Fire Drill

Most bad shared UI changes follow the same pattern. The team had some evidence, just not enough.

Watch for these mistakes:

  • treating import count as user impact
  • trusting graph output without opening real callers in source
  • editing tokens, primitives, or layout helpers before tracing wrappers
  • visualizing the whole application when the real question is local
  • assuming passing tests prove visual or accessibility safety
  • ignoring dead code and duplicate patterns that distort risk
  • asking an AI assistant to guess runtime behavior from structure alone

That last one is worth saying plainly.

Ask AI to surface evidence and unknowns, not to pretend uncertainty doesn’t exist.

Conclusion

Before changing shared UI, start with a component dependency graph. Narrow the problem to the local subgraph. Inspect real callers. Separate structural facts from the checks that still need human verification, especially props, styling, visual behavior, and accessibility.

That shift matters. Shared UI stops feeling like a fragile black box and starts looking like an inspectable system. You’re not gambling on memory anymore. You’re running an investigation.

A practical next step: pick one high-usage shared component this week, map its direct callers, trace the transitive callers to real screens, note the prop patterns in use, and write down the visual and accessibility checks you’d need before the next edit. If you want that structural map available inside your AI workflow, Pharaoh does this automatically via MCP.

Article Record

ReferencesPrimary sources used for this article
  1. Static components dependency graph detection with evaluation metrics in React.js projects
  2. Understanding Your UI as a Tree
  3. Create dependency diagrams from your code - Visual Studio (Windows)
  4. Building the exemONE Screen Dependency Map: A Codebase as Nodes and Edges | EXEM
  5. Visualize Dependencies In Design Systems
Update HistoryMeaningful revisions to this article
Initial publication.
← Back to blog