-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
New architecture #227
New architecture #227
Conversation
@a-eid I think you need to add |
- (NSDictionary *)getConstants | ||
{ | ||
UIWindow *window = [[UIApplication sharedApplication] keyWindow]; | ||
if (@available(iOS 11.0, *)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is iOS 10 still supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It prob was when the code was written, but it shouldn't be now so I can clean that up.
This is really cool! I've not really had a chance to play with the new architecture. What's the backwards compat like? |
@jacobp100 It should be fully backwards compatible. The new architecture is actually already used in RN core. |
Planning to release this as a prerelease soon to confirm backwards compat is still good. The only thing that might change is require a newer version of react native, but using the new architecture will be opt in still for a while. |
Out of curiosity, what will be the advantages of using the new architecture with this module ? :) |
For now I'm not using any new feature from the new architecture, but it will enable using rendering priorities which can be nice to have sync rendering when insets change and avoid flickers. It does enable more code sharing via c++, but the main goal of this PR is just maintain current features. |
example/ios/Podfile
Outdated
:hermes_enabled => true, | ||
:fabric_enabled => true, | ||
:app_path => "#{__dir__}/..", | ||
:config_file_dir => "#{__dir__}/../../..", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:config_file_dir => "#{__dir__}/../../..", | |
:config_file_dir => "#{__dir__}/../..", |
If __dir__
equal to PWD command, it will return system/user/path/react-native-xxxx/example/ios
and then we should go back to times to root folder, which is react-native-xxxx
Is is correct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see your point right now
const codegenConfigFileDir = path.join(confifDir, dependency);
So the fileDir
will be outside the library and then will point to that dependency. But the problem with that solution is that I have the other rn libraries in this dir and the codegen scans those dir, which are outside the project
As workaround I used a below command:
"preinstall": "cp ../package.json ./codegenConfig/react-native-pager-view && cp -R ../src ./codegenConfig/react-native-pager-view",
And changed the config_file_dir
:config_file_dir => "#{__dir__}/../codegenConfig",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Planning to make some improvements to config_file_dir. We want to be able to pass a direct path to a library, as well as supporting multiple values with an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, that seems like a better workaround than the one I have now 😅
example/package.json
Outdated
"react-native": "0.0.0-20211215-2008-f16cbe59e", | ||
"react-native-codegen": "^0.0.12", | ||
"react-native-gradle-plugin": "^0.0.3", | ||
"react-native-safe-area-context": "../" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering, why it has been added here, but probably I found a explanation for that
- the dep is added to package.json
- codegen recognize it as a dep
- using a custom path the codegen generates needed files
- in
postInstall
phase this dep is. removed from node modules to avoid duplication
Could you confirm, if my above thought are correct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's why, it's a hack to make codegen discover the library properly, while still using the source in the repo with the babel plugin alias to make dev simple.
Not sure if there's a better way to setup that, but for now that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great! I just left few small comments. I was focusing on C++ and iOS part.
} | ||
|
||
- (void)updateState:(facebook::react::State::Shared const &)state | ||
oldState:(facebook::react::State::Shared const &)oldState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can drop facebook::react
as there is already using namespace
on top of the file.
[self updateState]; | ||
} | ||
|
||
- (UIView *)findNearestProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be appropriate to log a warning in case a provider is not found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that there is no provider it will use its own view to get insets from, so I think it is correct to not log anything as it will still work properly.
[self invalidateSafeAreaInsets]; | ||
} | ||
|
||
- (void)invalidateSafeAreaInsets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: often methods on iOS have suffix "ifNecessary". It suggests to a reader that there is a condition that needs to be met for the action to happen.
Maybe this method could be named "updateStateIfNecessary"?
} | ||
|
||
auto currentStyle = yogaNode_.getStyle(); | ||
if (adjustedStyle.padding()[YGEdgeTop] != currentStyle.padding()[YGEdgeTop] || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we compare adjustedStyle != currentStyle
instead of comparing every value independently?
Alternatively, compare specifically only padding and margin instead of writing out all edges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comaping paddings / margin leads to this compiler error Invalid operands to binary expression ('IdxRef<YGEdge, &YGStyle::padding_>' and 'IdxRef<YGEdge, &YGStyle::padding_>')
. I assume it doesn't implement the proper compare functions in yoga.
right = | ||
valueFromEdges(props.yogaStyle.margin(), YGEdgeRight, YGEdgeHorizontal); | ||
} | ||
if (std::find(edges.begin(), edges.end(), "top") != edges.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could do following:
edges.find("top") != edges.end()
same result but it is easier to read.
I think free function std::find
is meant to be used in templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think find exists for std::vector, am I missing something?
Ideally this would be a bitmask or set, but that's what is generated by codegen so I can't change it.
c0dded4
to
7cec01a
Compare
Apologies for possibly using the wrong thread (couldn't find a better place). The release notes for 3.4.0 released 3 days ago mention
Isn't this a breaking change that should be done in a major version update? Reason I'm asking is because we've been getting some errors on CI during CocoaPods installation:
|
@friederbluemle I should have made this change as part of 4.0 in hindsight. Do you still need support for iOS < 11? In that case I would recommend staying on 3.3.x, or you can update the ios version in your podfile. |
I decided to revert the ios min version change, it will be done in v4 instead. |
Thank you @janicduplessis 👍 |
Summary
Test Plan
See updated contributing guide on how to run the example app.
Open the hooks example.