react-disappear
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

React Disappear

I wanted to give this library the name react-visible, but it is taken for an useless component. So back to the main! This component detects if the inner children are visible or not. With onDisappear: (visible: boolean) => void; can you get the current visible state

Install

# With NPM
npm add react-disappear

# With Yarn
yarn add react-disappear

# With bun
bun add react-disappear

# In some cases you'll need tslib, do this by:
npm add --save-dev tslib

How to use

Class Component requires an wrapper

import { Disappear } from "react-disappear";

function App() {
  return (
    <div>
      <Disappear
        as={"div"} // or custom components
        onDisappear={(state, ref) => {
          console.log(state);
        }}
        style={{ backgroundColor: "#fff" }}>
        <span>Content</span>
        <span>Content</span>
        <span>Content</span>
        <span>Content</span>
        <span>Content</span>
      </Disappear>
    </div>
  );
}

rct.renderAuto(App);

Package Sidebar

Install

npm i react-disappear

Weekly Downloads

54

Version

1.1.3

License

MIT

Unpacked Size

12.7 kB

Total Files

10

Last publish

Collaborators

  • der_googler