【发布时间】:2021-08-26 20:53:37
【问题描述】:
我正在尝试对子组件隐藏父组件选项卡。
在下面提供我的代码 sn-p 和沙箱
有人可以帮忙吗?任何帮助将不胜感激!
演示:https://codesandbox.io/s/material-demo-8je9d
我已经包含了下面的代码。
Tab2组件
import React, { useState } from "react";
import { Button, Modal } from "react-bootstrap";
function Tab2ComponentFunction(props) {
const { children, value, index, ...other } = props;
return <div />;
}
export default function Tab2Component(props) {
const [value, setValue] = React.useState(2);
const [Tab2Show, setTab2Show] = useState(false);
const onTab2Hide = () => {
alert("onTab2Hide");
setTab2Show(false);
setValue(0); //goto tab1
};
//const handleChange = (event, newValue) => {
// setValue(newValue);
//};
return (
<div>
<Button className="mr10" variant="light" onClick={() => {}}>
hide tab 2
</Button>
Tab2Component content
</div>
);
}
【问题讨论】:
标签: javascript html reactjs redux react-hooks