mirror of
https://github.com/zoriya/nitro.git
synced 2026-10-13 00:05:23 +00:00
* feat: Add base files * use type * clean header * Update ViewComponentDescriptor.hpp * Use it! * fix build error * comments * Update JSIRawPropsParser.hpp * remove raw prop parser ig * fix: remove deleted header from podspec
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
//
|
|
// Created by Marc Rousavy on 19.08.26.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
|
|
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 <typename TProps>
|
|
struct ViewPropsHolderState final {
|
|
public:
|
|
ViewPropsHolderState() = default;
|
|
explicit ViewPropsHolderState(const std::shared_ptr<TProps>& props) : _props(props) {}
|
|
|
|
public:
|
|
[[nodiscard]]
|
|
const std::shared_ptr<TProps>& getProps() const {
|
|
return _props;
|
|
}
|
|
|
|
public:
|
|
#ifdef ANDROID
|
|
ViewPropsHolderState(const ViewPropsHolderState& /* previousState */, folly::dynamic /* data */) {}
|
|
folly::dynamic getDynamic() const {
|
|
throw std::runtime_error("ViewPropsHolderState<T> does not support folly!");
|
|
}
|
|
react::MapBuffer getMapBuffer() const {
|
|
throw std::runtime_error("ViewPropsHolderState<T> does not support MapBuffer!");
|
|
};
|
|
#endif
|
|
|
|
private:
|
|
std::shared_ptr<TProps> _props;
|
|
};
|
|
|
|
} // namespace margelo::nitro
|