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

[core][iOS] Drop proxiedProperties prop #22280

Merged
merged 6 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
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
1,108 changes: 554 additions & 554 deletions apps/fabric-tester/ios/Podfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/expo-modules-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [iOS] Passed the app context instance down to dynamic types, object builders and convertibles. ([#21819](https://github.com/expo/expo/pull/21819) by [@tsapeta](https://github.com/tsapeta))
- [iOS] Use `jsi::WeakObject` for weak objects on Hermes. ([#21986](https://github.com/expo/expo/pull/21986) by [@tsapeta](https://github.com/tsapeta))
- [iOS] Removed legacyViewManager references from ExpoFabricView. ([#22089](https://github.com/expo/expo/pull/22089) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- [iOS] Dropped `proxiedProperties` prop. ([#22280](https://github.com/expo/expo/pull/22280) by [@tsapeta](https://github.com/tsapeta))

## 1.2.6 - 2023-03-20

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions packages/expo-modules-core/common/cpp/fabric/ExpoViewProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ namespace react = facebook::react;

namespace expo {

/**
Borrows the props map from the source props and applies the update given in the raw props.
*/
std::unordered_map<std::string, folly::dynamic> propsMapFromProps(const ExpoViewProps &sourceProps, const react::RawProps &rawProps) {
// Move the contents of the source props map – the source props instance will not be used anymore.
std::unordered_map<std::string, folly::dynamic> propsMap = std::move(sourceProps.propsMap);
Copy link
Member Author

Choose a reason for hiding this comment

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

@Kudo do you think the move here is safe? As far as I know, the source props will not be used anymore and the propsMap is used only once per the lifetime of the ExpoViewProps instance 🤔 We could do a copy if you're not sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

at first glance, it's strange to me because there's const ExpoViewProps &sourceProps in the function declaration and we won't like to mutate the sourceProps. i think it's from react-native to pass sourceProps as a const reference. however, since the propsMaps is controlled by us. that's somehow reasonable. let's keep it as-is.


// Iterate over values in the raw props object.
// Note that it contains only updated props.
rawProps.iterateOverValues([&propsMap](react::RawPropsPropNameHash hash, const char *name, const react::RawValue &value) {
std::string propName(name);
propsMap[propName] = (folly::dynamic)value;
});

return propsMap;
}

ExpoViewProps::ExpoViewProps(const react::PropsParserContext &context,
const ExpoViewProps &sourceProps,
const react::RawProps &rawProps)
: ViewProps(context, sourceProps, rawProps),
proxiedProperties(
facebook::react::convertRawProp(context, rawProps, "proxiedProperties", sourceProps.proxiedProperties, {})) {
}
propsMap(propsMapFromProps(sourceProps, rawProps)) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
propsMap(propsMapFromProps(sourceProps, rawProps)) {}
propsMap(std::move(propsMapFromProps(sourceProps, rawProps))) {}

not pretty sure whether it's correct. if yes, nice to have a move semantic here.

Copy link
Member Author

Choose a reason for hiding this comment

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

screenshot_2023-04-29_at_18 52 50

Since this object is already temporary, doing a move would be redundant and slower

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, i was wrong for this, the move is not necessary because it's already temporary object.


} // namespace expo
5 changes: 4 additions & 1 deletion packages/expo-modules-core/common/cpp/fabric/ExpoViewProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class ExpoViewProps final : public facebook::react::ViewProps {

#pragma mark - Props

const folly::dynamic proxiedProperties;
/**
A map with props stored as `folly::dynamic` objects.
*/
std::unordered_map<std::string, folly::dynamic> propsMap;
};

} // namespace expo
Expand Down
7 changes: 7 additions & 0 deletions packages/expo-modules-core/ios/Fabric/ExpoFabricView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public class ExpoFabricView: ExpoFabricViewObjC {
viewManager.callLifecycleMethods(withType: .didUpdateProps, forView: view)
}

/**
Returns a bool value whether the view supports prop with the given name.
*/
public override func supportsProp(withName name: String) -> Bool {
return viewManagerPropDict?.index(forKey: name) != nil
}

/**
The function that is called by Fabric when the view is unmounted and is being enqueued for recycling.
It can also be called on app reload, so be careful to wipe out any dependencies specific to the currently running AppContext.
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-modules-core/ios/Fabric/ExpoFabricViewObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

- (void)viewDidUpdateProps;

- (BOOL)supportsPropWithName:(nonnull NSString *)name;

- (void)prepareForRecycle;

#pragma mark - Methods injected to the class in runtime
Expand Down
Loading