Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing undefined #93

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "animated",
"version": "0.2.1",
"version": "0.2.2",
"description": "Declarative Animations Library for React and React Native",
"main": "lib/index.js",
"scripts": {
Expand Down
44 changes: 24 additions & 20 deletions src/createAnimatedComponent.js
Expand Up @@ -8,14 +8,14 @@
*
* @flow
*/
'use strict';
"use strict";

var React = require('react');
var AnimatedProps = require('./AnimatedProps');
var ApplyAnimatedValues = require('./injectable/ApplyAnimatedValues');
var React = require("react");
var AnimatedProps = require("./AnimatedProps");
var ApplyAnimatedValues = require("./injectable/ApplyAnimatedValues");

function createAnimatedComponent(Component: any): any {
var refName = 'node';
var refName = "node";

class AnimatedComponent extends React.Component {
_propsAnimated: AnimatedProps;
Expand Down Expand Up @@ -45,16 +45,17 @@ function createAnimatedComponent(Component: any): any {
// need to re-render it. In this case, we have a fallback that uses
// forceUpdate.
var callback = () => {
var didUpdate = ApplyAnimatedValues.current(this.refs[refName], this._propsAnimated.__getAnimatedValue(), this);
var didUpdate = ApplyAnimatedValues.current(
this.refs[refName],
this._propsAnimated.__getAnimatedValue(),
this,
);
if (didUpdate === false) {
this.forceUpdate();
}
};

this._propsAnimated = new AnimatedProps(
nextProps,
callback,
);
this._propsAnimated = new AnimatedProps(nextProps, callback);

// When you call detach, it removes the element from the parent list
// of children. If it goes to 0, then the parent also detaches itself
Expand All @@ -72,15 +73,18 @@ function createAnimatedComponent(Component: any): any {
}

render() {
const { style, ...other} = this._propsAnimated.__getValue();

return (
<Component
{...other}
style={ApplyAnimatedValues.transformStyles(style)}
ref={refName}
/>
);
const props = this._propsAnimated.__getValue();
if (props.style) {
return (
<Component
{...props}
style={ApplyAnimatedValues.transformStyles(props.style)}
ref={refName}
/>
);
}

return <Component {...props} ref={refName} />;
}
}
AnimatedComponent.propTypes = {
Expand All @@ -102,7 +106,7 @@ function createAnimatedComponent(Component: any): any {
// );
// }
// }
}
},
};

return AnimatedComponent;
Expand Down