From 9fb5df2e68f8e9d6fa49f18b1c19149996a630f4 Mon Sep 17 00:00:00 2001 From: Igor Furgala Date: Tue, 14 Oct 2025 10:51:45 +0200 Subject: [PATCH] fix: unmounting component --- .../enriched/EnrichedTextInputViewManager.kt | 4 +-- .../EnrichedTextInputMeasurementManager.cpp | 1 - .../EnrichedTextInputMeasurementManager.h | 2 -- .../EnrichedTextInputProps.cpp | 31 +++++++++++++++++++ .../EnrichedTextInputProps.h | 22 +++++++++++++ .../EnrichedTextInputShadowNode.cpp | 2 +- .../EnrichedTextInputShadowNode.h | 4 +-- 7 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.cpp create mode 100644 android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.h diff --git a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt index 9435ca9cc..028267a56 100644 --- a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +++ b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt @@ -10,7 +10,6 @@ import com.facebook.react.uimanager.StateWrapper import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewDefaults import com.facebook.react.uimanager.ViewManagerDelegate -import com.facebook.react.uimanager.ViewProps import com.facebook.react.uimanager.annotations.ReactProp import com.facebook.react.viewmanagers.EnrichedTextInputViewManagerDelegate import com.facebook.react.viewmanagers.EnrichedTextInputViewManagerInterface @@ -132,7 +131,7 @@ class EnrichedTextInputViewManager : SimpleViewManager(), view?.htmlStyle = HtmlStyle(view, style) } - @ReactProp(name = ViewProps.COLOR, customType = "Color") + @ReactProp(name = "color", customType = "Color") override fun setColor(view: EnrichedTextInputView?, color: Int?) { view?.setColor(color) } @@ -174,6 +173,7 @@ class EnrichedTextInputViewManager : SimpleViewManager(), view?.setPadding(left, top, right, bottom) } + @ReactProp(name = "isOnChangeHtmlSet", defaultBoolean = true) override fun setIsOnChangeHtmlSet(view: EnrichedTextInputView?, value: Boolean) { // this prop isn't used on Android as of now, but the setter must be present } diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp index 0906ddbb8..2024cb232 100644 --- a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.cpp @@ -10,7 +10,6 @@ namespace facebook::react { Size EnrichedTextInputMeasurementManager::measure( SurfaceId surfaceId, - const EnrichedTextInputViewProps& props, LayoutConstraints layoutConstraints) const { const jni::global_ref& fabricUIManager = contextContainer_->at>("FabricUIManager"); diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h index 353e9f5bf..43ba8c1bf 100644 --- a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputMeasurementManager.h @@ -4,7 +4,6 @@ #include #include -#include namespace facebook::react { @@ -16,7 +15,6 @@ namespace facebook::react { Size measure( SurfaceId surfaceId, - const EnrichedTextInputViewProps& props, LayoutConstraints layoutConstraints) const; private: diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.cpp b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.cpp new file mode 100644 index 000000000..54450f5a2 --- /dev/null +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.cpp @@ -0,0 +1,31 @@ +#include "EnrichedTextInputProps.h" +#include +#include + +namespace facebook::react { + + EnrichedTextInputProps::EnrichedTextInputProps( + const PropsParserContext &context, + const EnrichedTextInputProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) {} + +#ifdef RN_SERIALIZABLE_STATE + ComponentName EnrichedTextInputProps::getDiffPropsImplementationTarget() const { + return "EnrichedTextInputView"; +} + +folly::dynamic EnrichedTextInputProps::getDiffProps( + const Props* prevProps) const { + static const auto defaultProps = EnrichedTextInputProps(); + const EnrichedTextInputProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } + folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); + return result; +} +#endif + +} // namespace facebook::react diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.h b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.h new file mode 100644 index 000000000..2414ac99b --- /dev/null +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputProps.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include + +namespace facebook::react { + + class EnrichedTextInputProps final : public ViewProps { + public: + EnrichedTextInputProps() = default; + EnrichedTextInputProps(const PropsParserContext& context, const EnrichedTextInputProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + +#ifdef RN_SERIALIZABLE_STATE + ComponentName getDiffPropsImplementationTarget() const override; + folly::dynamic getDiffProps(const Props* prevProps) const override; +#endif + }; + +} // namespace facebook::react diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp index 8d89e816e..da4b99ab0 100644 --- a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.cpp @@ -28,7 +28,7 @@ extern const char EnrichedTextInputComponentName[] = "EnrichedTextInputView"; const LayoutContext &layoutContext, const LayoutConstraints &layoutConstraints) const { - return measurementsManager_->measure(getSurfaceId(), getConcreteProps(), layoutConstraints); + return measurementsManager_->measure(getSurfaceId(), layoutConstraints); } } // namespace facebook::react diff --git a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h index 6ff3e3ce6..22ce4babf 100644 --- a/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h +++ b/android/src/main/new_arch/react/renderer/components/RNEnrichedTextInputViewSpec/EnrichedTextInputShadowNode.h @@ -2,9 +2,9 @@ #include "EnrichedTextInputMeasurementManager.h" #include "EnrichedTextInputState.h" +#include "EnrichedTextInputProps.h" #include -#include #include namespace facebook::react { @@ -15,7 +15,7 @@ JSI_EXPORT extern const char EnrichedTextInputComponentName[]; */ class EnrichedTextInputShadowNode final : public ConcreteViewShadowNode< EnrichedTextInputComponentName, - EnrichedTextInputViewProps, + EnrichedTextInputProps, EnrichedTextInputViewEventEmitter, EnrichedTextInputState> { public: