-
Notifications
You must be signed in to change notification settings - Fork 102
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
Conversation
src/createAnimatedComponent.js
Outdated
const { style, ...other} = this._propsAnimated.__getValue(); | ||
const props = this._propsAnimated.__getValue(); | ||
if (props.style) { | ||
props.style = ApplyAnimatedValues.transformStyles(props.style) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change mutates the object, previously it did not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I realize that, but attempting to avoid an if statement with rendering the component and or creating another new object to spread on w/ props.
The __getValue
always returns a new object https://github.com/animatedjs/animated/blob/master/src/AnimatedProps.js#L37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Why avoid an if statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, personal preference.
Generally speaking I like my render functions to have a single return.
render() {
const props = this._propsAnimated.__getValue();
if (props.style) {
return (
<Component
{...props}
style={ApplyAnimatedValues.transformStyles(props.style)}
ref={refName}
/>
);
}
return <Component {...props} ref={refName} />;
}
This is fine by me, accomplishes the same thing.
@ljharb Let me know if this fix works for your system and we can merge and release it. |
No description provided.