Skip to content

Commit

Permalink
Merge commit 'f53267f7031dec9f8e61c679bf786d025d634eb6' into amgleitm…
Browse files Browse the repository at this point in the history
…an/0.64-merge-2020-mm-dd
  • Loading branch information
amgleitman committed Aug 19, 2021
2 parents 3275f0d + f53267f commit e6d2b0a
Show file tree
Hide file tree
Showing 26 changed files with 618 additions and 141 deletions.
2 changes: 1 addition & 1 deletion Libraries/Alert/NativeAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {DefaultInputsArray} from './AlertMacOS'; // TODO(macOS GH#774)
export type Args = {|
title?: string,
message?: string,
buttons?: Array<Object>, // TODO: have a better type
buttons?: Array<Object>, // TODO(T67565166): have a better type
type?: string,
defaultValue?: string,
cancelButtonKey?: string,
Expand Down
26 changes: 24 additions & 2 deletions Libraries/Animated/src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

'use strict';

const View = require('../../Components/View/View');
const {AnimatedEvent} = require('./AnimatedEvent');
const AnimatedProps = require('./nodes/AnimatedProps');
const React = require('react');
Expand All @@ -20,7 +21,18 @@ const setAndForwardRef = require('../../Utilities/setAndForwardRef');
export type AnimatedComponentType<
Props: {+[string]: mixed, ...},
Instance,
> = React.AbstractComponent<$ObjMap<Props, () => any>, Instance>;
> = React.AbstractComponent<
$ObjMap<
Props &
$ReadOnly<{
passthroughAnimatedPropExplicitValues?: React.ElementConfig<
typeof View,
>,
}>,
() => any,
>,
Instance,
>;

function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
Component: React.AbstractComponent<Props, Instance>,
Expand Down Expand Up @@ -65,6 +77,7 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
// However, setNativeProps can only be implemented on leaf native
// components. If you want to animate a composite component, you need to
// re-render it. In this case, we have a fallback that uses forceUpdate.
// This fallback is also called in Fabric.
_animatedPropsCallback = () => {
if (this._component == null) {
// AnimatedProps is created in will-mount because it's used in render.
Expand Down Expand Up @@ -119,6 +132,10 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
_attachProps(nextProps) {
const oldPropsAnimated = this._propsAnimated;

if (nextProps === oldPropsAnimated) {
return;
}

this._propsAnimated = new AnimatedProps(
nextProps,
this._animatedPropsCallback,
Expand Down Expand Up @@ -160,10 +177,15 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
});

render() {
const props = this._propsAnimated.__getValue();
const {style = {}, ...props} = this._propsAnimated.__getValue() || {};
const {style: passthruStyle = {}, ...passthruProps} =
this.props.passthroughAnimatedPropExplicitValues || {};
const mergedStyle = {...style, ...passthruStyle};
return (
<Component
{...props}
{...passthruProps}
style={mergedStyle}
ref={this._setComponentRef}
// The native driver updates views directly through the UI thread so we
// have to make sure the view doesn't get optimized away because it cannot
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ class ScrollView extends React.Component<Props, State> {
return (
<StickyHeaderComponent
key={key}
nativeID={'StickyHeader-' + key}
ref={ref => this._setStickyHeaderRef(key, ref)}
nextHeaderLayoutY={this._headerLayoutYs.get(
this._getKeyForIndex(nextIndex, childArray),
Expand Down
Loading

0 comments on commit e6d2b0a

Please sign in to comment.