npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

delay-unmount

v0.1.7

Published

A simple component and hook to create unmount and mount animations in reactjs

Downloads

13

Readme

Delay Unmount

Usage

You can animate your React component while mounting and unmounting.

Example

CSS

How it will work

We should assign a classname to the given component ( Delay ) and style it using css ( Animations ) . To assign the classname you should use the unmount and mount props.

How to use

  • You will get a component named Delay.

  • It will accept 4 props ( Each prop should be in the same name )

    component - The React component which you need the delay effect( Animation )

    dependancy - Show or hide the component ( data-type : boolean )

    delay - delayTime which you time (in milliseconds)

    unmount - This should be a class name, which you can add style to it using css. The style or animation apply to this class will worked when your React component is unmounting.

    mount - This should be a class name, which you can add style to it using css. The style or animation apply to this class will worked when your React component is mounting.

Features

  • Animating components while mounting and unmounting

  • You can use different unmount and mount animations for different components ( Because each component can have a specific className )

If you are a performance guy

  • For the mounting and unmounting process it will take only 4 rerenders except the initial render.

  • If the parent component rerenders This component won't be rerendered ( memoized ).

NOTE

  • If you are using it, your component will wrapped inside a div tag. ( It may cause speficity problems when you selecting your component through CSS ) . You can see the div tag when you inspect your component after it was mounted.

No problem There is a solution If you are not like to wrap inside a div tag.

There is custom hook named useDelayUnmount.

This hook accepts two values

    • dependancy - Show or hide the component ( data-type : boolean )

    • delay - DelayTime which you time (in milliseconds)

It will return a boolean value ( true or false ). Now you can use it to apply the logic to the component.

Pass two props to you component

    • show : the value you getting from the custom hook
    • visible : Your dependancy value

Then take those props from your component

Next were are going to use our logic to implement the unmount animation

  • Here we are assigning a classname to the parent element of the component, the unmount classname will only available when unmounting the Component

    • default - Your default classnames
    • unmount - class name that that you want animate while unmounting
    • mount - class name that that you want animate while mounting

Now you can add the animation or style you needed when unmounting the component through your css file by selecting the classname that you gave.

Some times It may be confusing for you, You can refer this github Repo to get the example code.

Live example site.

You can contact me through

Thank you