[GH-ISSUE #245] Components that render @opentui/react components do not support key prop #63

Closed
opened 2026-03-02 23:44:14 +03:00 by kerem · 2 comments
Owner

Originally created by @macklinu on GitHub (Oct 31, 2025).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/245

import { test, expect } from "bun:test"

test("components that wrap opentui react components support React key prop", () => {
  const Double = ({ children }: { children: number }) => <text>{children * 2}</text>

  const numbers = [1, 2, 3]

  expect(() => (
    <box>
      {numbers.map((number) => (
        <Double key={number}>{number}</Double>
      ))}
    </box>
  )).not.toThrow()
})

results in:

src/components/index.test.tsx:11:17 - error TS2322: Type '{ children: number; key: number; }' is not assignable to type '{ children: number; }'.
  Property 'key' does not exist on type '{ children: number; }'.

11         <Double key={number}>{number}</Double>

I would expect the Double component to accept the key prop. I'm having trouble figuring out where to make this change locally after poking around the @opentui/react types otherwise I would have submitted a PR.

Originally created by @macklinu on GitHub (Oct 31, 2025). Original GitHub issue: https://github.com/anomalyco/opentui/issues/245 ```tsx import { test, expect } from "bun:test" test("components that wrap opentui react components support React key prop", () => { const Double = ({ children }: { children: number }) => <text>{children * 2}</text> const numbers = [1, 2, 3] expect(() => ( <box> {numbers.map((number) => ( <Double key={number}>{number}</Double> ))} </box> )).not.toThrow() }) ``` results in: ``` src/components/index.test.tsx:11:17 - error TS2322: Type '{ children: number; key: number; }' is not assignable to type '{ children: number; }'. Property 'key' does not exist on type '{ children: number; }'. 11 <Double key={number}>{number}</Double> ``` I would expect the Double component to accept the `key` prop. I'm having trouble figuring out where to make this change locally after poking around the `@opentui/react` types otherwise I would have submitted a PR.
kerem 2026-03-02 23:44:14 +03:00
  • closed this issue
  • added the
    bug
    react
    labels
Author
Owner

@macklinu commented on GitHub (Oct 31, 2025):

Actually figured it out - https://github.com/sst/opentui/pull/246.

<!-- gh-comment-id:3474080503 --> @macklinu commented on GitHub (Oct 31, 2025): Actually figured it out - https://github.com/sst/opentui/pull/246.
Author
Owner

@msmps commented on GitHub (Oct 31, 2025):

fixed by #246

<!-- gh-comment-id:3474137140 --> @msmps commented on GitHub (Oct 31, 2025): fixed by #246
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#63
No description provided.