use-layout-animation
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

use-layout-animation

This module makes it easy to use React Native's LayoutAnimation with React Hooks. It triggers a layout animation whenever some values change. It is used similar to React's useEffect.

Installation

yarn add use-layout-animation

Usage

import { useLayoutAnimation } from 'use-layout-animation';
 
function Component(props) {
    useLayoutAnimation([props.animateWhenThisPropChanges]);
    // ...
}

Advanced usage

function Component(props) {
    useLayoutAnimation(
        // props that trigger a layout animation when they change
        [props.animateWhenThisPropChanges, props.orWhenThisPropChanges],
        // LayoutAnimationConfig
        // For reference, see all available presets here:
        // https://facebook.github.io/react-native/docs/layoutanimation#presets
        LayoutAnimation.Presets.spring,
        // Callback when animations end
        () => alert('layout animation done'),
    );
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    49
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    49
  • 0.0.1
    1

Package Sidebar

Install

npm i use-layout-animation

Weekly Downloads

50

Version

0.0.2

License

none

Unpacked Size

4.91 kB

Total Files

6

Last publish

Collaborators

  • fant