v2.0.0
2.0.0 (2019-03-10)
Complete rewrite using React hooks!
- Ends support for React versions < 16.8.x
- Library now exports a custom hook in lieu of a render prop component
- Adds support for unmounting the contents of the Collapse element when closed
import React from 'react';
import useCollapse from 'react-collapsed';
function Demo() {
const {getCollapseProps, getToggleProps, isOpen} = useCollapse();
return (
<>
<button {...getToggleProps()}>{isOpen ? 'Collapse' : 'Expand'}</button>
<section {...getCollapseProps()}>Collapsed content 🙈</section>
</>
);
}