Skip to content

Comments

fix(tarko): resolve react key spread warning and hooks render issue#1435

Merged
ulivz merged 1 commit intomainfrom
fix/react-key-spread-warning
Sep 8, 2025
Merged

fix(tarko): resolve react key spread warning and hooks render issue#1435
ulivz merged 1 commit intomainfrom
fix/react-key-spread-warning

Conversation

@ulivz
Copy link
Member

@ulivz ulivz commented Sep 8, 2025

Summary

Fixed React key spread warning and hooks render consistency issue in @tarko/agent-ui.

Issues resolved:

  • React warning: "A props object containing a 'key' prop is being spread into JSX" in ChatInput.tsx
  • "Rendered more hooks than during the previous render" error in ModelSelector.tsx

Changes:

  • Replaced {...{ ['ke' + 'y']: 'value' }} with direct key="value" prop in motion buttons
  • Moved handleModelChange callback before conditional returns to ensure consistent hook order

Logs:

ChatInput.tsx:496 Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, initial: ..., animate: ..., exit: ..., transition: ..., whileTap: ..., whileHover: ..., type: ..., onClick: ..., disabled: ..., className: ..., title: ..., children: ...};
  <ForwardRef(motion.button) {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {initial: ..., animate: ..., exit: ..., transition: ..., whileTap: ..., whileHover: ..., type: ..., onClick: ..., disabled: ..., className: ..., title: ..., children: ...};
  <ForwardRef(motion.button) key={someKey} {...props} />
    at ChatInput (http://localhost:8888/static/js/index.js:14014:11)
    at div
    at div
    at ChatPanel (http://localhost:8888/static/js/index.js:10765:101)
    at div
    at div
    at Shell (http://localhost:8888/static/js/index.js:10063:11)
    at div
    at div
    at div
    at div
    at div
    at Layout (http://localhost:8888/static/js/index.js:10166:25)
    at SessionRouter (http://localhost:8888/static/js/index.js:10362:11)
    at RenderedRoute (http://localhost:8888/static/js/lib-router.js:7214:5)
    at Routes (http://localhost:8888/static/js/lib-router.js:7948:5)
    at App (http://localhost:8888/static/js/index.js:9934:159)
    at Router (http://localhost:8888/static/js/lib-router.js:7882:15)
    at BrowserRouter (http://localhost:8888/static/js/lib-router.js:5792:5)
    at ReplayModeProvider (http://localhost:8888/static/js/index.js:1555:11)
    at Provider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:167915:3)
    at AgentWebUI (http://localhost:8888/static/js/index.js:10490:97)
react-dom.development.js:15688 Uncaught Error: Rendered more hooks than during the previous render.
    at NavbarModelSelector (ModelSelector.tsx:281:1)
react-dom.development.js:18704 The above error occurred in the <NavbarModelSelector> component:

    at NavbarModelSelector (http://localhost:8888/static/js/index.js:17682:11)
    at div
    at div
    at DynamicNavbarCenter (http://localhost:8888/static/js/index.js:18542:11)
    at div
    at DefaultPropsProvider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:16928:3)
    at RtlProvider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:17061:7)
    at ThemeProvider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:16044:5)
    at ThemeProvider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:17141:5)
    at ThemeProvider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:14929:14)
    at Navbar (http://localhost:8888/static/js/index.js:18294:117)
    at div
    at Layout (http://localhost:8888/static/js/index.js:10166:25)
    at SessionRouter (http://localhost:8888/static/js/index.js:10362:11)
    at RenderedRoute (http://localhost:8888/static/js/lib-router.js:7214:5)
    at Routes (http://localhost:8888/static/js/lib-router.js:7948:5)
    at App (http://localhost:8888/static/js/index.js:9934:159)
    at Router (http://localhost:8888/static/js/lib-router.js:7882:15)
    at BrowserRouter (http://localhost:8888/static/js/lib-router.js:5792:5)
    at ReplayModeProvider (http://localhost:8888/static/js/index.js:1555:11)
    at Provider (http://localhost:8888/static/js/vendors-node_modules_pnpm_mui_material_5_17_1__emotion_react_11_14_0__types_react_18_3_23_rea-73611c.js:167915:3)
    at AgentWebUI (http://localhost:8888/static/js/index.js:10490:97)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
react-dom.development.js:15688 Uncaught Error: Rendered more hooks than during the previous render.
    at NavbarModelSelector (ModelSelector.tsx:281:1)
fileTypeUtils.ts:66 WebSocket connection to 'ws://localhost:8888/rsbuild-hmr?compilationId=web__tarko_agent-ui' failed: Connection closed before receiving a handshake response
hmr.js:122 [HMR] WebSocket connection er

Checklist

  • [] Added or updated necessary tests (Optional).
  • Updated documentation to align with changes (Optional).
  • Verified no breaking changes, or prepared solutions for any occurring breaking changes (Optional).
  • My change does not involve the above items.

@netlify
Copy link

netlify bot commented Sep 8, 2025

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit b005ecb
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/68beb5a2821562000881e884
😎 Deploy Preview https://deploy-preview-1435--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ulivz ulivz merged commit f3f4bf6 into main Sep 8, 2025
10 checks passed
@ulivz ulivz deleted the fix/react-key-spread-warning branch September 8, 2025 11:31
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