mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Pass context through to all prop parser (core changes)
Summary: Unfortunately, parsing some props requires stateful context - namely, PlatformColor on Android. We explored several different options but they all seemed inferior to the approach of using ContextContainer, and most would require using global state. By introducing this change everywhere as early as possible, we can avoid later pain. It is likely that some prop, on some platform, will require this mechanism. We'll be ready for it! Because we can pass a constref of the ContextContainer through to all props and because the context and context data is never retained by prop parsers, perf and memory hit should be ~0. This diff contains core changes only. Leaf changes to all props structs and conversions files will be in next diff(s). Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D29838789 fbshipit-source-id: f5090e7f02eb6e8fbe0ef4dd201e7d12104a3e3c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8b1b7f7126
commit
09b9422516
@@ -275,6 +275,7 @@ void Binding::startSurface(
|
||||
layoutContext.pointScaleFactor = pointScaleFactor_;
|
||||
|
||||
auto surfaceHandler = SurfaceHandler{moduleName->toStdString(), surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler->getContextContainer());
|
||||
surfaceHandler.setProps(initialProps->consume());
|
||||
surfaceHandler.constraintLayout({}, layoutContext);
|
||||
|
||||
@@ -336,6 +337,7 @@ void Binding::startSurfaceWithConstraints(
|
||||
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
|
||||
auto surfaceHandler = SurfaceHandler{moduleName->toStdString(), surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler_->getContextContainer());
|
||||
surfaceHandler.setProps(initialProps->consume());
|
||||
surfaceHandler.constraintLayout(constraints, context);
|
||||
|
||||
|
||||
@@ -87,9 +87,10 @@ CoreComponentsRegistry::initHybrid(
|
||||
[](EventDispatcher::Weak const &eventDispatcher,
|
||||
ContextContainer::Shared const &contextContainer)
|
||||
-> ComponentDescriptorRegistry::Shared {
|
||||
auto registry = CoreComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(
|
||||
{eventDispatcher, contextContainer});
|
||||
auto registry =
|
||||
CoreComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(
|
||||
{eventDispatcher, contextContainer}, contextContainer);
|
||||
auto mutableRegistry =
|
||||
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
|
||||
mutableRegistry->setFallbackComponentDescriptor(
|
||||
|
||||
Reference in New Issue
Block a user