Skip to content

How to get view related to nativeId #433

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

Open
MikePendo opened this issue Dec 1, 2021 · 1 comment
Open

How to get view related to nativeId #433

MikePendo opened this issue Dec 1, 2021 · 1 comment

Comments

@MikePendo
Copy link

MikePendo commented Dec 1, 2021

Is it possible to add the prop nativeID to a view like follows:
<View nativeID="viewId">...</View>
And then use that id to locate the view in my native android and iOS code so I could apply some native method on it. If it is then an example would be appreciated.

I did find the following method on the IOS:

/**
 * Finds a view that is tagged with nativeID as its nativeID prop
 * with the associated rootTag root tag view hierarchy. Returns the
 * view if found, nil otherwise.
 *
 * @param nativeID the id reference to native component relative to root view.
 * @param rootTag the react tag of root view hierarchy from which to find the view.
 */
- (UIView *)viewForNativeID:(NSString *)nativeID withRootTag:(NSNumber *)rootTag;

But the implementation seems to append nativeId with root tag (as key ) and then get it from Map so I am not sure the description of the rootTag param is correct.
In case I done have the root tag how would I start get the rootView?

@MikePendo MikePendo changed the title How to get view related to nattiveId How to get view related to nativeId Dec 1, 2021
@savelichalex
Copy link

Not sure if it's still valid, but you can take a look on how I did it in our project.

https://github.com/tonlabs/UIKit/blob/development/kit/inputs/ios/UIInputAccessoryView%2BScrollView.m#L196

Basically every view has access to a rootTag AFAIR.

PS. It's probably not a good idea anymore to depend on UIManager, as (if I'm not mistaken) it's going to be deprecated in Fabric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants