react 的函数组件 自定义事件

项目 中 ice +react  的函数组件 

自定义事件  :   

changeDetails
// 父组件

import StateHistory from './stateHistory';

const [details, setDetails] = useState<boolean>(true);

<StateHistory changeDetails={(bol) => setDetails(bol)} />

// 子组件

const StateHistory = (props) => {
        <Button
          type="primary"
          shape="round"
          onClick={() => props.changeDetails(true)}
        >
          返回
        </Button>

};

export default StateHistory;

 

posted @ 2023-05-17 17:36  cielw  阅读(172)  评论(0)    收藏  举报