fix: lint errors in widget-renderer.tsx and layout.tsx

未关闭
#2 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
领域
frontend, tooling

调研方向

Start by running pnpm lint and inspect apps/app/src/components/generative-ui/widget-renderer.tsx at the two reported effects and the unused description prop, then review layout.tsx at the Google Fonts link. Done means the Plus Jakarta Sans load uses next/font, the effect lint errors and unused prop warning are resolved, and pnpm lint passes without errors or warnings.

由索引模型根据 Issue 内容生成。

描述

bug

Description

The pnpm lint CI check is failing with 2 errors and 2 warnings.

Errors

1. react-hooks/set-state-in-effect in widget-renderer.tsx:414
// apps/app/src/components/generative-ui/widget-renderer.tsx
useEffect(() => {
  if (!active) return;
  setIndex(0);  // ← setState called synchronously in effect
  const interval = setInterval(() => {
    setIndex((i) => (i + 1) % LOADING_PHRASES.length);
  }, 1800);
  return () => clearInterval(interval);
}, [active]);

Fix: Reset the index outside the effect (e.g. derive from active changing, or use a ref).

2. react-hooks/set-state-in-effect in widget-renderer.tsx:457
useEffect(() => {
  if (!html || !iframeRef.current) return;
  if (html === committedHtmlRef.current) return;
  committedHtmlRef.current = html;
  iframeRef.current.srcdoc = assembleDocument(html);
  setLoaded(false);  // ← setState called synchronously in effect
  setHeight(0);
}, [html]);

Fix: Restructure so loaded/height are derived from html changes without synchronous setState in the effect body.

Warnings

3. Unused description prop — widget-renderer.tsx:424
export function WidgetRenderer({ title, description, html }: WidgetRendererProps) {
//                                      ^^^^^^^^^^^ defined but never used

Fix: Either use the prop or prefix with underscore (_description).

4. Custom font loaded in layout.tsx instead of next/fontlayout.tsx:15
<link
  href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap"
  rel="stylesheet"
/>

Fix: Use next/font/google to load Plus Jakarta Sans for automatic optimization and self-hosting.

主要语言
TypeScript
星标
1.6k
派生
202
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CopilotKit/OpenGenerativeUI 的其他 Issue

查看 CopilotKit/OpenGenerativeUI 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。