react-component/collapse

Allow setting isActive on a Panel in an uncontrolled Collapse

thomasmery opened this issue · 2 comments

Hi there,

thanks for this component, it really helps a lot

only thing I'm having difficulty with is being able to simply open panel programatically by passing a isActive prop to the panel without having to go the whole controlled way (with activeKey on the Collapse)

is it possible?

thanks a lot

I think for now you can control it programatically by passing defaultActiveKey={['1'],['2']} to collapse element if you want to have by default open 1 and 2 would be nice if we can pass to panel just isActive as true :)

@isuke01 I'm not having much luck with defaultActiveKey={['1'],['2']}. Rather than having panel 1 and 2 open by default it seems to only evaluate the last array (['2']) and therefore only render panel 2 open. Any ideas?

Edit: CodeSandbox Link

Edit: I've somehow got this working in production but not in this demo 🤔

Edit: Got it to work in the demo by using an array of strings (defaultActiveKey={["1", "2"]}) instead of an array (maybe? not actually sure what this is) of arrays of strings (defaultActiveKey={['1'],['2']}). The CodeSandbox has been updated.