Commit 48a0a652 authored by GuanHua's avatar GuanHua

fix:收藏管理不能切换tab的问题

parent 49a6c51f
...@@ -14,18 +14,22 @@ interface CollectionPropsType { ...@@ -14,18 +14,22 @@ interface CollectionPropsType {
const Collection: React.FC<CollectionPropsType> = (props) => { const Collection: React.FC<CollectionPropsType> = (props) => {
const { query: { type } } = props.location const { query: { type } } = props.location
const [defaultTab, setDefaultTab] = useState<string>("commodity") const [tabKey, setTabKey] = useState<string>("commodity")
useEffect(() => { useEffect(() => {
if (type) { if (type) {
setDefaultTab(type) setTabKey(type)
} }
}, [type]) }, [type])
const handleChange = (key) => {
setTabKey(key)
}
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<div className={styles.collection_wrap}> <div className={styles.collection_wrap}>
<Tabs activeKey={defaultTab} className={styles.collection_tabs} > <Tabs activeKey={tabKey} className={styles.collection_tabs} onChange={handleChange} >
<TabPane tab="商品收藏" key="commodity"> <TabPane tab="商品收藏" key="commodity">
<Commodity /> <Commodity />
</TabPane> </TabPane>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment