mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
feat: Add getConcretePropsShared() (#48710)
Summary: Adds `getConcretePropsShared()` to `ConcreteShadowNode.h`. I need this in Nitro Views to update state in-place without throwing away the old state object and creating a new one each time. From reading the code it seems like you use this pattern a lot tho where you create new State objects each time - so let me know if my thing is a bad idea.. ## Changelog: - [INTERNAL] [ADDED] Add `getConcretePropsShared()` to `ConcreteShadowNode.h` <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/48710 Test Plan: Use in Nitro Reviewed By: sammy-SC Differential Revision: D68495697 Pulled By: javache fbshipit-source-id: e2caa34befcaef2191ec161442c40596cc7de132
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ab77bdf471
commit
f830f2c667
@@ -105,6 +105,16 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
||||
return static_cast<const ConcreteProps&>(*props_);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a concrete props object associated with the node, as a shared_ptr.
|
||||
* Thread-safe after the node is sealed.
|
||||
*/
|
||||
const std::shared_ptr<const ConcreteProps>& getConcreteSharedProps() const {
|
||||
react_native_assert(
|
||||
BaseShadowNodeT::props_ && "Props must not be `nullptr`.");
|
||||
return std::static_pointer_cast<const ConcreteProps>(props_);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a concrete event emitter object associated with the node.
|
||||
* Thread-safe after the node is sealed.
|
||||
|
||||
Reference in New Issue
Block a user