Skip to content

Commit 9a87db2

Browse files
javachefacebook-github-bot
authored andcommitted
Remove initialProps handling for legacy createAnimatedComponent
Summary: Changelog: [Internal] Remove additional Animated logic under Fabric that's no longer required Reviewed By: jehartzog Differential Revision: D40513977 fbshipit-source-id: 1e96366377ca4c3bf032d830b5641ab658462ce8
1 parent 880e889 commit 9a87db2

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

Libraries/Animated/createAnimatedComponent.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
5353
_prevComponent: any;
5454
_propsAnimated: AnimatedProps;
5555
_eventDetachers: Array<Function> = [];
56-
_initialAnimatedProps: Object;
5756

5857
// Only to be used in this file, and only in Fabric.
5958
_animatedComponentId: string = `${animatedComponentNextId++}:animatedComponent`;
@@ -199,18 +198,7 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
199198
});
200199

201200
render(): React.Node {
202-
// When rendering in Fabric and an AnimatedValue is used, we keep track of
203-
// the initial value of that Value, to avoid additional prop updates when
204-
// this component re-renders
205-
const initialPropsIfFabric = this._isFabric()
206-
? this._initialAnimatedProps
207-
: null;
208-
209-
const animatedProps =
210-
this._propsAnimated.__getValue(initialPropsIfFabric) || {};
211-
if (!this._initialAnimatedProps) {
212-
this._initialAnimatedProps = animatedProps;
213-
}
201+
const animatedProps = this._propsAnimated.__getValue() || {};
214202

215203
const {style = {}, ...props} = animatedProps;
216204
const {style: passthruStyle = {}, ...passthruProps} =

Libraries/Animated/nodes/AnimatedProps.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,12 @@ export default class AnimatedProps extends AnimatedNode {
3636
this._callback = callback;
3737
}
3838

39-
__getValue(initialProps: ?Object): Object {
39+
__getValue(): Object {
4040
const props: {[string]: any | ((...args: any) => void)} = {};
4141
for (const key in this._props) {
4242
const value = this._props[key];
4343
if (value instanceof AnimatedNode) {
44-
// During initial render we want to use the initial value of both natively and non-natively
45-
// driven nodes. On subsequent renders, we cannot use the value of natively driven nodes
46-
// as they may not be up to date, so we use the initial value to ensure that values of
47-
// native animated nodes do not impact rerenders.
48-
if (value instanceof AnimatedStyle) {
49-
props[key] = value.__getValue(initialProps?.style);
50-
} else if (!initialProps || !value.__isNative) {
51-
props[key] = value.__getValue();
52-
} else if (initialProps.hasOwnProperty(key)) {
53-
props[key] = initialProps[key];
54-
}
44+
props[key] = value.__getValue();
5545
} else if (value instanceof AnimatedEvent) {
5646
props[key] = value.__getHandler();
5747
} else {

Libraries/Animated/nodes/AnimatedStyle.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,24 @@ export default class AnimatedStyle extends AnimatedWithChildren {
3434
}
3535

3636
// Recursively get values for nested styles (like iOS's shadowOffset)
37-
_walkStyleAndGetValues(
38-
style: any,
39-
initialStyle: ?Object,
40-
): {[string]: any | {...}} {
37+
_walkStyleAndGetValues(style: any): {[string]: any | {...}} {
4138
const updatedStyle: {[string]: any | {...}} = {};
4239
for (const key in style) {
4340
const value = style[key];
4441
if (value instanceof AnimatedNode) {
45-
// During initial render we want to use the initial value of both natively and non-natively
46-
// driven nodes. On subsequent renders, we cannot use the value of natively driven nodes
47-
// as they may not be up to date, so we use the initial value to ensure that values of
48-
// native animated nodes do not impact rerenders.
49-
if (!initialStyle || !value.__isNative) {
50-
updatedStyle[key] = value.__getValue();
51-
} else if (initialStyle.hasOwnProperty(key)) {
52-
updatedStyle[key] = initialStyle[key];
53-
}
42+
updatedStyle[key] = value.__getValue();
5443
} else if (value && !Array.isArray(value) && typeof value === 'object') {
5544
// Support animating nested values (for example: shadowOffset.height)
56-
updatedStyle[key] = this._walkStyleAndGetValues(value, initialStyle);
45+
updatedStyle[key] = this._walkStyleAndGetValues(value);
5746
} else {
5847
updatedStyle[key] = value;
5948
}
6049
}
6150
return updatedStyle;
6251
}
6352

64-
__getValue(initialStyle: ?Object): Object {
65-
return this._walkStyleAndGetValues(this._style, initialStyle);
53+
__getValue(): Object {
54+
return this._walkStyleAndGetValues(this._style);
6655
}
6756

6857
// Recursively get animated values for nested styles (like iOS's shadowOffset)

0 commit comments

Comments
 (0)