Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: margin auto conversion in fabric #35635

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ReactCommon/react/renderer/components/view/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <folly/Conv.h>
#include <folly/dynamic.h>
#include <glog/logging.h>
#include <react/config/ReactNativeConfig.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/components/view/primitives.h>
#include <react/renderer/core/LayoutMetrics.h>
Expand Down Expand Up @@ -382,7 +383,8 @@ inline void fromRawValue(
} else if (value.hasType<std::string>()) {
const auto stringValue = (std::string)value;
if (stringValue == "auto") {
result = YGValueUndefined;
auto reactNativeConfig = context.contextContainer.at<std::shared_ptr<ReactNativeConfig const>>("ReactNativeConfig");
Copy link
Contributor

@NickGerleman NickGerleman Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion code here is going to be a relatively hot path, so it might make sense to cache this (e.g. in a static variable), since I think the config values shouldn't change over app lifetime. Can make that change when importing if I get around to it before EOW, but wanted to give a quick heads up.

result = reactNativeConfig->getBool("react_fabric:treat_auto_as_undefined") ? YGValueUndefined : YGValueAuto;
return;
} else {
if (stringValue.back() == '%') {
Expand Down