@ej-hooks/use-fade-in
React Hook to fade in any element.
Installation
yarn
yarn add @ej-hooks/use-fade-in
npm
npm i @ej-hooks/use-fade-in
Usage
import React from 'react';
import useFadeIn from '@ej-hooks/use-fade-in';
function App() {
const fadeIn = useFadeIn(5, 10);
return <h1 {...fadeIn}>This will fade in.</h1>;
}
Arguments
Argument | Type | Description | Required | Default value |
---|---|---|---|---|
duration | number | Sets the duration of the transition. In seconds | no | 1 |
delay | number | Delays of transition's start. In seconds | no | 0 |
Return
Return value | Type | Description | Default value |
---|---|---|---|
ref | React Ref | A ref created to fadeIn the element | null |
style | Object | Style object | {opacity:0} |
It's recommended to just spread the returned object on the element as shown in the Usage section above.