Registry / web-framework / react-tween-state

react-tween-state

JSON →
library0.1.5jsnpmunverified

react-tween-state is an animation utility for React applications that enables smooth interpolation of component state values over time. It provides a `this.tweenState` method, which functions similarly to `this.setState`, but initiates an animated transition of a state property to a target value over a specified duration. The library relies heavily on React's deprecated mixin system (`React.createClass`) for integration into components. The current and likely final stable version is 0.1.5, released in 2016, and the project has been unmaintained since then. Its core differentiators, such as direct state manipulation via mixins and an imperative `tweenState` API, are now considered anti-patterns in modern React development, which favors declarative component-based animation libraries and hooks. It does not support newer React features or functional components.

npm install react-tween-state
INSTALL
IMPORT
SIG · REACT-TWEEN-STATE
R
react-tween-state
web-frameworkjavascriptv0.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tweenState (main import)
const tweenState = require('react-tween-state');
import tweenState from 'react-tween-state'
This library is CommonJS-only and relies on React mixins, which are incompatible with modern ES module imports and functional components.
Mixin
var App = React.createClass({ mixins: [tweenState.Mixin], /* ... */ });
class App extends React.Component { /* ... */ }
The core functionality is exposed via a React mixin, which is deprecated in React v0.13+ and removed in React v16+. Not compatible with modern class components or functional components.
easingTypes
tweenState.easingTypes.easeInOutQuad
import { easingTypes } from 'react-tween-state'
Easing functions are exposed as properties on the main `tweenState` object after requiring the package. There is no direct named export for `easingTypes`.

Demonstrates how to integrate `react-tween-state` using a `React.createClass` component with its mixin, animate a state property (`left`), and retrieve the tweening value during render. This requires an older React setup.

const tweenState = require('react-tween-state'); const React = require('react'); const ReactDOM = require('react-dom'); // Required for rendering const App = React.createClass({ mixins: [tweenState.Mixin], getInitialState: function() { return { left: 0 }; }, handleClick: function() { // Animate 'left' property of the state this.tweenState('left', { easing: tweenState.easingTypes.easeInOutQuad, duration: 500, endValue: this.state.left === 0 ? 400 : 0, onEnd: () => console.log('Animation ended!') }); }, render: function() { const style = { position: 'absolute', width: 50, height: 50, backgroundColor: 'lightblue', left: this.getTweeningValue('left'), // Retrieve the current tweening value cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'white' }; return ( <div style={style} onClick={this.handleClick}> Click Me </div> ); } }); // This code needs an HTML file with <div id="root"></div> and // older versions of React/ReactDOM (e.g., v15) to run successfully. // For example, in an HTML file with script tags for React, ReactDOM, and this example: // ReactDOM.render(<App />, document.getElementById('root'));
Debug
Known issues
breakingThis library is built exclusively for older versions of React (pre-v0.13 through v15) and relies on `React.createClass` and the mixin system. It is fundamentally incompatible with React v16 and newer, which removed `React.createClass` and deprecated mixins.
fix
Use modern animation libraries like `react-spring`, `framer-motion`, or `react-transition-group` that are compatible with class components and functional components/hooks.
affects: >=0.13.0
gotchaThe library is unmaintained since 2016 (version 0.1.5) and receives no updates, bug fixes, or security patches. Using it in production introduces significant technical debt and potential vulnerabilities.
fix
Migrate to an actively maintained animation library compatible with your React version.
affects: >=0.1.5
gotcha`react-tween-state` does not offer official TypeScript definitions. While community types might exist, they are not guaranteed to be up-to-date or accurate, leading to potential type-related issues when used in TypeScript projects.
fix
Consider using an animation library that provides first-party TypeScript support or migrate to JavaScript for the animation logic if sticking with `react-tween-state` is unavoidable.
affects: >=0.1.0
gotchaThe `this.tweenState` call immediately sets the underlying state field to its `endValue` and then interpolates a separate 'tweening value' accessible via `this.getTweeningValue`. This can be counter-intuitive if you expect the actual component state to reflect the interpolated value at all times.
fix
Always retrieve the animated value using `this.getTweeningValue(path)` within your `render` method, not directly from `this.state[path]`, when an animation is in progress.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: React.createClass is not a function
Attempting to use `React.createClass` (required by `react-tween-state`) with React v16 or newer, where this API has been removed.
fix
This library is incompatible with modern React. You must downgrade your React version to v15 or earlier, or preferably, choose a modern animation library that uses class components or functional components/hooks.
Invariant Violation: Mixins are deprecated and not supported in React 16+.
React versions from v0.13.0 onwards deprecated mixins, and v16 removed them entirely. Using `mixins: [tweenState.Mixin]` triggers this error.
fix
See the fix for `TypeError: React.createClass is not a function`. The library cannot be used with modern React versions due to its reliance on deprecated features.
TypeError: this.tweenState is not a function
The `tweenState` method is provided via the `tweenState.Mixin`. This error occurs if `tweenState.Mixin` is not included in the component's `mixins` array, or if the component is not created using `React.createClass`.
fix
Ensure your component is defined using `React.createClass` and includes `tweenState.Mixin` in its `mixins` array. Example: `var App = React.createClass({ mixins: [tweenState.Mixin], /* ... */ });`
Uncaught ReferenceError: require is not defined
Using `require()` syntax directly in a browser environment without a CommonJS bundler (like Webpack or Browserify) in place, or without a global `require` implementation.
fix
This library is designed for CommonJS environments. For browser usage, you need to use a module bundler to process the `require()` calls or ensure the library is included via a script tag in a way that exposes `tweenState` globally, though a bundler is the standard approach.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies
reactrequiredProvides the React runtime environment and component model (specifically `React.createClass` and mixins) that this library integrates with, requiring older React versions.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
react-tween-state — npm install react-tween-state · libregistry