web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.21k stars 107 forks source link

[Bug]: Page crashes when using <Tabs /> with a single <Tab /> as children #971

Closed chenjiahan closed 2 months ago

chenjiahan commented 2 months ago

Version

Rspress v1.18.1

Details

Page crashes when using with a single as children, for example:

<Tabs>
  <Tab label="foo">foo</Tab>
</Tabs>

Related code: https://github.com/web-infra-dev/rspress/blob/0625b783ca81ea04436320c5a4c6eb837a07944c/packages/theme-default/src/components/Tabs/index.tsx#L57-L60

The children is JSX when there is only a single item. Maybe we should use React.Children.map() instead of children.map

this issue war originally reported by @colinaaa ❤️

Reproduce link

https://github.com/web-infra-dev/rspress

Reproduce Steps

  1. add the code
  2. pnpm dev
chenjiahan commented 2 months ago

I will take this