Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
* @format
*/

import View from '../Components/View/View';
import useMergeRefs from '../Utilities/useMergeRefs';
import useAnimatedProps from './useAnimatedProps';
import * as React from 'react';

// $FlowFixMe[deprecated-type]
export type AnimatedProps<Props: {...}> = $ObjMap<Props, () => any>;
export type AnimatedProps<Props: {...}> = $ObjMap<
Props &
$ReadOnly<{
passthroughAnimatedPropExplicitValues?: React.ElementConfig<typeof View>,
}>,
() => any,
>;

export type AnimatedComponentType<
Props: {...},
Expand All @@ -36,9 +43,19 @@ export default function createAnimatedComponent<TProps: {...}, TInstance>(
// transformed and Pressable, onPress will not work after transform
// without these passthrough values.
// $FlowFixMe[prop-missing]
const {style} = reducedProps;
const {passthroughAnimatedPropExplicitValues, style} = reducedProps;
const {style: passthroughStyle, ...passthroughProps} =
passthroughAnimatedPropExplicitValues ?? {};
const mergedStyle = {...style, ...passthroughStyle};

return <Component {...reducedProps} style={style} ref={ref} />;
return (
<Component
{...reducedProps}
{...passthroughProps}
style={mergedStyle}
ref={ref}
/>
);
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@ const ScrollViewStickyHeaderWithForwardedRef: React.AbstractComponent<

const child = React.Children.only<$FlowFixMe>(props.children);

const passthroughAnimatedPropExplicitValues =
isFabric && translateY != null
? {
style: {transform: [{translateY: translateY}]},
}
: null;

return (
/* $FlowFixMe[prop-missing] passthroughAnimatedPropExplicitValues isn't properly
included in the Animated.View flow type. */
<Animated.View
collapsable={false}
nativeID={props.nativeID}
Expand All @@ -277,7 +286,11 @@ const ScrollViewStickyHeaderWithForwardedRef: React.AbstractComponent<
child.props.style,
styles.header,
{transform: [{translateY: animatedTranslateY}]},
]}>
]}
passthroughAnimatedPropExplicitValues={
passthroughAnimatedPropExplicitValues
}>
>
{React.cloneElement(child, {
style: styles.fill, // We transfer the child style to the wrapper.
onLayout: undefined, // we call this manually through our this._onLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,13 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
`;

exports[`public API should not change unintentionally Libraries/Animated/createAnimatedComponent.js 1`] = `
"export type AnimatedProps<Props: { ... }> = $ObjMap<Props, () => any>;
"export type AnimatedProps<Props: { ... }> = $ObjMap<
Props &
$ReadOnly<{
passthroughAnimatedPropExplicitValues?: React.ElementConfig<typeof View>,
}>,
() => any,
>;
export type AnimatedComponentType<
Props: { ... },
+Instance = mixed,
Expand Down Expand Up @@ -8399,6 +8405,14 @@ exports[`public API should not change unintentionally Libraries/Utilities/DebugE
"
`;

exports[`public API should not change unintentionally Libraries/Utilities/DevLoadingView.js 1`] = `
"declare module.exports: {
showMessage(message: string, type: \\"load\\" | \\"refresh\\"): void,
hide(): void,
};
"
`;

exports[`public API should not change unintentionally Libraries/Utilities/DevSettings.js 1`] = `
"declare let DevSettings: {
addMenuItem(title: string, handler: () => mixed): void,
Expand Down Expand Up @@ -8516,14 +8530,6 @@ export interface IPerformanceLogger {
"
`;

exports[`public API should not change unintentionally Libraries/Utilities/DevLoadingView.js 1`] = `
"declare module.exports: {
showMessage(message: string, type: \\"load\\" | \\"refresh\\"): void,
hide(): void,
};
"
`;

exports[`public API should not change unintentionally Libraries/Utilities/NativeAppearance.js 1`] = `
"export type * from \\"../../src/private/specs/modules/NativeAppearance\\";
declare export default typeof NativeAppearance;
Expand Down