Javascript 使按钮在手风琴中向上滑动

Javascript 使按钮在手风琴中向上滑动,javascript,reactjs,accordion,slide,Javascript,Reactjs,Accordion,Slide,我有一个手风琴,上面有上下滑动的按钮,就像这样 我制作了一些功能组件和类似的东西: <SlideButtonContainer> <SlideButton title="Title goes here"> Content goes here </SlideButton> <SlideButton title="Title goes here"> Cont

我有一个手风琴,上面有上下滑动的按钮,就像这样

我制作了一些功能组件和类似的东西:

<SlideButtonContainer>
    <SlideButton title="Title goes here">
        Content goes here
    </SlideButton>
    <SlideButton title="Title goes here">
        Content goes here
    </SlideButton>
</SlideButtonContainer>
SlideButtonContainer
只是一个样式化的div

export default function SlideButtonContainer(props) {
    return (
        <div className="slideButtonContainer">
            { props.children }
        </div>  
    );
}
导出默认功能SlideButtonContainer(道具){
返回(
{props.children}
);
}
已解决。 在
SlideButtonContainer
中,我在
render
上使用
React.cloneElement
并将refs设置为其子项,我可以将子项函数用于此循环:

for (var ref in this.refs) {
    this.refs[ref].slideUp();
}

您是否可以更新您的问题,将所有这些组件的实现细节包括在一个状态中?将状态移动到parent:@Branislav,但这需要为每组幻灯片按钮制作一个组件。我不想那样做
for (var ref in this.refs) {
    this.refs[ref].slideUp();
}