Skip to content

v2.0.0

Compare
Choose a tag to compare
@roginfarrer roginfarrer released this 10 Mar 20:17
2be7f8f

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>
    </>
  );
}