From c541a838876899548e4100e2a0a94f7fbd7cbca5 Mon Sep 17 00:00:00 2001
From: Rylan <1217013295@qq.com>
Date: Fri, 12 Jan 2024 08:20:49 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Tabs=20=E6=B8=B2=E6=9F=93?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A5=E4=B8=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/Tabs.js | 82 +++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 52 deletions(-)
diff --git a/components/Tabs.js b/components/Tabs.js
index 6f08aada..eb1e2e69 100644
--- a/components/Tabs.js
+++ b/components/Tabs.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react'
+import { useState } from 'react';
/**
* Tabs切换标签
@@ -6,59 +6,37 @@ import React, { useState } from 'react'
* @returns
*/
const Tabs = ({ className, children }) => {
- const [currentTab, setCurrentTab] = useState(0)
+ const [currentTab, setCurrentTab] = useState(0);
- if (!children) {
- return <>>
+ const validChildren = children.filter(c => c);
+
+ if (validChildren.length === 0) {
+ return <>>;
}
- children = children.filter(c => c && c !== '')
-
- let count = 0
- children.forEach(e => {
- if (e) {
- count++
- }
- })
-
- if (count === 0) {
- return <>>
- }
-
- if (count === 1) {
- return