// // Created by Marc Rousavy on 19.08.26. // #pragma once #include #include #include namespace margelo::nitro { using namespace facebook; /** * A class that conforms to `react::StateData`, which * only holds the given `TProps` via a `shared_ptr`. * * This is useful to set props via a custom route through * JNI on Android, instead of going through react-native's * JNI/folly prop parser which is type-limited. */ template struct ViewPropsHolderState final { public: ViewPropsHolderState() = default; explicit ViewPropsHolderState(std::shared_ptr props) : _props(std::move(props)) {} public: [[nodiscard]] const std::shared_ptr& getProps() const { return _props; } public: #ifdef ANDROID ViewPropsHolderState(const ViewPropsHolderState& /* previousState */, folly::dynamic /* data */) {} folly::dynamic getDynamic() const { throw std::runtime_error("ViewPropsHolderState does not support folly!"); } react::MapBuffer getMapBuffer() const { throw std::runtime_error("ViewPropsHolderState does not support MapBuffer!"); }; #endif private: std::shared_ptr _props; }; } // namespace margelo::nitro