diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index da3f5037a90a2b..a17d6350c65abc 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -20,6 +20,8 @@ import Platform from '../../Utilities/Platform'; import type {LayoutEvent} from '../../Types/CoreEventTypes'; +import ScrollViewStickyHeaderInjection from './ScrollViewStickyHeaderInjection'; + const AnimatedView = AnimatedImplementation.createAnimatedComponent(View); export type Props = $ReadOnly<{ @@ -328,4 +330,8 @@ const styles = StyleSheet.create({ }, }); -module.exports = ScrollViewStickyHeader; +const SHToExport: React.AbstractComponent< + Props, + $ReadOnly<{setNextHeaderY: number => void, ...}>, +> = ScrollViewStickyHeaderInjection.unstable_SH ?? ScrollViewStickyHeader; +module.exports = SHToExport; diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js b/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js new file mode 100644 index 00000000000000..ab8684ffb6818a --- /dev/null +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +import typeof ScrollViewStickyHeader from './ScrollViewStickyHeader'; + +export default { + unstable_SH: (null: ?ScrollViewStickyHeader), +}; diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index 4135959bb43710..d5b5edf3c2af50 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -210,25 +210,21 @@ class Switch extends React.Component { // This is necessary in case native updates the switch and JS decides // that the update should be ignored and we should stick with the value // that we have in JS. - const nativeProps = {}; const value = this.props.value === true; - - if (this._lastNativeValue !== value) { - nativeProps.value = value; - } + const nativeValue = this._lastNativeValue !== value ? value : null; if ( - Object.keys(nativeProps).length > 0 && + nativeValue != null && this._nativeSwitchRef && this._nativeSwitchRef.setNativeProps ) { if (Platform.OS === 'android') { AndroidSwitchCommands.setNativeValue( this._nativeSwitchRef, - nativeProps.value, + nativeValue, ); } else { - SwitchCommands.setValue(this._nativeSwitchRef, nativeProps.value); + SwitchCommands.setValue(this._nativeSwitchRef, nativeValue); } } } diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 2186c2431a49e7..43e2060eebca23 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -38,27 +38,27 @@ void PrintMutationInstructionRelative( // This corresponds exactly with JS. enum class AnimationType { - None, - Spring, - Linear, - EaseInEaseOut, - EaseIn, - EaseOut, - Keyboard + None = 0, + Spring = 1, + Linear = 2, + EaseInEaseOut = 4, + EaseIn = 8, + EaseOut = 16, + Keyboard = 32 }; enum class AnimationProperty { - NotApplicable, - Opacity, - ScaleX, - ScaleY, - ScaleXY + NotApplicable = 0, + Opacity = 1, + ScaleX = 2, + ScaleY = 4, + ScaleXY = 8 }; enum class AnimationConfigurationType { - Noop, // for animation placeholders that are not animated, and should be + Noop = 0, // for animation placeholders that are not animated, and should be // executed once other animations have completed - Create, - Update, - Delete + Create = 1, + Update = 2, + Delete = 4 }; // This corresponds exactly with JS. diff --git a/ReactCommon/react/renderer/graphics/conversions.h b/ReactCommon/react/renderer/graphics/conversions.h index f3420295b2ed57..a80eda0b63e4bb 100644 --- a/ReactCommon/react/renderer/graphics/conversions.h +++ b/ReactCommon/react/renderer/graphics/conversions.h @@ -20,10 +20,10 @@ namespace react { #pragma mark - Color inline void fromRawValue(const RawValue &value, SharedColor &result) { - float red; - float green; - float blue; - float alpha; + float red = 0; + float green = 0; + float blue = 0; + float alpha = 0; if (value.hasType()) { auto argb = (int64_t)value; @@ -40,9 +40,8 @@ inline void fromRawValue(const RawValue &value, SharedColor &result) { green = items.at(1); blue = items.at(2); alpha = length == 4 ? items.at(3) : 1.0f; - } else { - abort(); } + result = colorFromComponents({red, green, blue, alpha}); } diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 577e88e366b291..77be82e032e444 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -151,6 +151,11 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { registry.find(mutation.newChildShadowView.tag) != registry.end()); auto oldStubView = registry[mutation.newChildShadowView.tag]; react_native_assert(oldStubView->tag != 0); + if ((ShadowView)(*oldStubView) != mutation.oldChildShadowView) { + LOG(ERROR) + << "UPDATE mutation assertion failure: oldChildShadowView doesn't match oldStubView: [" + << mutation.oldChildShadowView.tag << "]"; + } react_native_assert( (ShadowView)(*oldStubView) == mutation.oldChildShadowView); oldStubView->update(mutation.newChildShadowView); diff --git a/packages/rn-tester/js/examples/Switch/SwitchExample.js b/packages/rn-tester/js/examples/Switch/SwitchExample.js index 1acbb65c765608..3a562410e399bf 100644 --- a/packages/rn-tester/js/examples/Switch/SwitchExample.js +++ b/packages/rn-tester/js/examples/Switch/SwitchExample.js @@ -135,6 +135,7 @@ class ColorSwitchExample extends React.Component<{...}, $FlowFixMeState> { return ( this.setState({colorFalseSwitchIsOn: value})} style={{marginBottom: 10}} thumbColor="#0000ff" @@ -145,6 +146,7 @@ class ColorSwitchExample extends React.Component<{...}, $FlowFixMeState> { value={this.state.colorFalseSwitchIsOn} /> this.setState({colorTrueSwitchIsOn: value})} thumbColor="#0000ff" trackColor={{ @@ -169,11 +171,13 @@ class EventSwitchExample extends React.Component<{...}, $FlowFixMeState> { this.setState({eventSwitchIsOn: value})} style={{marginBottom: 10}} value={this.state.eventSwitchIsOn} /> this.setState({eventSwitchIsOn: value})} style={{marginBottom: 10}} value={this.state.eventSwitchIsOn} @@ -182,6 +186,7 @@ class EventSwitchExample extends React.Component<{...}, $FlowFixMeState> { this.setState({eventSwitchRegressionIsOn: value}) } @@ -189,6 +194,7 @@ class EventSwitchExample extends React.Component<{...}, $FlowFixMeState> { value={this.state.eventSwitchRegressionIsOn} /> this.setState({eventSwitchRegressionIsOn: value}) } @@ -210,30 +216,35 @@ exports.description = 'Native boolean input'; exports.examples = [ { title: 'Switches can be set to true or false', + name: 'basic', render(): React.Element { return ; }, }, { title: 'Switches can be disabled', + name: 'disabled', render(): React.Element { return ; }, }, { title: 'Change events can be detected', + name: 'events', render(): React.Element { return ; }, }, { title: 'Switches are controlled components', + name: 'controlled', render(): React.Element { - return ; + return ; }, }, { title: 'Custom colors can be provided', + name: 'custom-colors', render(): React.Element { return ; },