{"id":15397037,"url":"https://github.com/ryanhefner/react-animate-props","last_synced_at":"2025-08-16T23:49:09.109Z","repository":{"id":23446797,"uuid":"98348479","full_name":"ryanhefner/react-animate-props","owner":"ryanhefner","description":"React higher order component and hook for transforming your favorite components to animate prop values on change.","archived":false,"fork":false,"pushed_at":"2023-01-06T01:31:31.000Z","size":1297,"stargazers_count":8,"open_issues_count":11,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-18T08:03:25.690Z","etag":null,"topics":["animate-prop-values","higher-order-component","props","react","react-animate-props","react-hook","react-hooks","tween-settings"],"latest_commit_sha":null,"homepage":"https://www.pkgstats.com/pkg:react-animate-props","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanhefner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ryanhefner","patreon":"ryanhefner","open_collective":"ryanhefner","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-07-25T20:45:56.000Z","updated_at":"2023-03-04T04:12:37.000Z","dependencies_parsed_at":"2023-01-13T23:19:00.281Z","dependency_job_id":null,"html_url":"https://github.com/ryanhefner/react-animate-props","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ryanhefner/react-animate-props","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-animate-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-animate-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-animate-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-animate-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanhefner","download_url":"https://codeload.github.com/ryanhefner/react-animate-props/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-animate-props/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270786281,"owners_count":24644562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animate-prop-values","higher-order-component","props","react","react-animate-props","react-hook","react-hooks","tween-settings"],"created_at":"2024-10-01T15:35:57.761Z","updated_at":"2025-08-16T23:49:09.082Z","avatar_url":"https://github.com/ryanhefner.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ryanhefner","https://patreon.com/ryanhefner","https://opencollective.com/ryanhefner"],"categories":[],"sub_categories":[],"readme":"# react-animate-props\n\nReact HOC (higher order component) method, and React Hook for transforming\nyour favorite components to animate prop values on change.\n\nThis package uses [Tweenkle](https://github.com/ryanhefner/tweenkle) for handling\nthe tweening of prop values. It’s not as full-featured as [GSAP](https://github.com/greensock/GreenSock-JS),\nbut it works pretty well for basic value and object tweening.\n\n## Install\n\nVia [npm](https://npmjs.com/package/react-animate-props)\n\n```sh\nnpm install --save react-animate-props\n```\n\nVia [Yarn](https://yarn.fyi/react-animate-props)\n\n```sh\nyarn add react-animate-props\n```\n\n## How to use\n\n`react-animate-props` now offers two(!) ways for you to animate the props in both\nyour class-based, and functional, React components.\n\n### Hook\n\n`useAnimateProps`\n\n#### Parameters\n\n* `prop : Number` - Value to animate\n* `options : Object` - Options to define the tween properties to use.\n\n__Default options:__\n\n```js\n{\n  delay: 0,                           // Delay to apply before the tween starts\n  duration: 1000,                     // Duration of the tween in milliseconds\n  ease: Easing.Quad.Out,              // Ease to use for the tween, @see [Tweenkle](https://github.com/ryanhefner/tweenkle) for options\n  onAnimateProgress: value =\u003e value,  // Callback to use during the tweening process, as well as being able to manipulate the value during the tween\n  onAnimateComplete: value =\u003e value,  // Callback for when the tween has completed, as well as being able to manipulate the final value of the tween\n}\n```\n\n#### Example\n\n```js\nimport React from 'react';\nimport { Easing } from 'tweenkle';\nimport { useAnimateProps } from 'react-animate-props';\n\nconst AnimatedNumberLabel = ({ number }) =\u003e {\n  const animatedNumber = useAnimateProps(number, {\n    ease: Easing.Quad.In,\n    delay: 500,\n    duration: 1500,\n    onAnimateProgress: value =\u003e {\n      return Math.round(value);\n    },\n    onAnimateComplete: value =\u003e {\n      return Math.round(value);\n    },\n  });\n\n  return \u003cspan\u003e{animatedNumber}\u003c/span\u003e;\n};\n\nexport default AnimatedNumberLabel;\n```\n\n### HOC (Higher Order Component)\n\n`animateProps` is a [higher order component](https://facebook.github.io/react/docs/higher-order-components.html)\nthat allows you to easily create components who’s props animate when changed.\n\nWhether you’re writing a new component, or would like to make an animated version\nof an existing component, just export your component and pass it through, `animateProps`.\n\n#### Parameters\n\n* `component:Class` - Class to apply `animateProps` logic to.\n\n* `defaultProps:Object` - Default props declared for the component being animated. (Default: `{}`)\n\n#### Properties\n\n* `animatedProps:Object` - Object defining which props to animate, and the tween\nsettings for each. `animateProps` uses the [Tweenkle](https://github.com/ryanhefner/tweenkle)\ntweening library, specifically a `Tween` instance, and you can pass whatever props that\nlibrary supports via the tween settings. You can find out more by reading the\n[Tweenkle README](https://github.com/ryanhefner/tweenkle).\n\n* `onAnimateProgress:Function` - Callback available to manipulate the `prop` before\nit is applied to the state. (Example: `(prop, value) =\u003e { return { [prop]: value }; }`)\n\n* `onAnimateComplete:Function` - Callback fired when the animation for a `prop` completes.\n(Example: `(prop, value, tweensActive) =\u003e {}`)\n\n#### Example\n\n```js\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport animateProps from 'react-animate-props';\nimport { Easing } from 'tweenkle';\n\nclass AnimatedNumberLabel extends Component {\n  render() {\n    const {\n      number,\n    } = this.props;\n\n    return (\n      \u003cspan\u003e\n        {number}\n      \u003c/span\u003e\n    );\n  }\n}\n\nAnimatedNumberLabel.propTypes = {\n  animatedProps: PropTypes.object,\n  number: PropTypes.number,\n  onAnimateProgress: PropTypes.func,\n};\n\nAnimatedNumberLabel.defaultProps = {\n  animatedProps: {\n    number: {\n      ease: Easing.Quad.In,\n      delay: 500,\n      duration: 1500,\n    },\n  },\n  number: 0,\n  onAnimateProgress: (prop, value) =\u003e {\n    return {\n      [prop]: Math.round(value),\n    };\n  },\n  onAnimateComplete: (prop, value, tweensActive) =\u003e {\n    return {\n      [prop]: Math.round(value),\n    };\n  },\n};\n\nexport default animateProps(\n  AnimatedNumberLabel,\n  AnimatedNumberLabel.defaultProps\n);\n```\n\n## License\n\n[MIT](LICENSE) © [Ryan Hefner](https://www.ryanhefner.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Freact-animate-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanhefner%2Freact-animate-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Freact-animate-props/lists"}