Skip to content

Refactor useArtifact hook for improved clarity#1472

Open
Sujaicodes wants to merge 1 commit intovercel:mainfrom
Sujaicodes:patch-2
Open

Refactor useArtifact hook for improved clarity#1472
Sujaicodes wants to merge 1 commit intovercel:mainfrom
Sujaicodes:patch-2

Conversation

@Sujaicodes
Copy link
Copy Markdown

We can merge useArtifactSelector into useArtifact so that selectors read directly from the SWR cache, while keeping all logic and functionality identical. This removes redundant SWR calls and memo layers.
Single SWR call for the artifact — no redundant useArtifactSelector call needed.
Selector functionality preserved via selectArtifact(selector). Example usage:
const title = selectArtifact(a => a.title);
3.Cleaner memoization — only one useMemo for the returned object.
4.Fully backward-compatible — existing artifact, setArtifact, metadata, and setMetadata logic works exactly the same.

We can merge useArtifactSelector into useArtifact so that selectors read directly from the SWR cache, while keeping all logic and functionality identical. This removes redundant SWR calls and memo layers.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 1, 2026

@Sujaicodes is attempting to deploy a commit to the Templates Test vtest314 Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Build-breaking import of removed useArtifactSelector export in shell.tsx and console.tsx.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant