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

[ANDROID] Allow using a custom RNCWebView in New Architecture #3586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marco-saia-datadog
Copy link

What does this PR do?

Adds a createViewInstance override to RNCWebViewManager in new architecture, to allow using a custom RNCWebView, in accordance with the official guide for Android Customization.

Usage

With this change, the official guide will still be relevant:

@ReactModule(name = CustomWebViewManager.REACT_CLASS)
public class CustomWebViewManager extends RNCWebViewManager {
  /* This name must match what we're referring to in JS */
  protected static final String REACT_CLASS = "RCTCustomWebView";

  protected static class CustomWebViewClient extends RNCWebViewClient { }

  protected static class CustomWebView extends RNCWebView {
    public CustomWebView(ThemedReactContext reactContext) {
      super(reactContext);
    }
  }

  // This is currently not possible in New Architecture
  @Override
  protected RNCWebView createViewInstance(ThemedReactContext reactContext) {
    return super.createViewInstance(reactContext, new CustomWebView(reactContext));
  }

  @Override
  public String getName() {
    return REACT_CLASS;
  }

  @Override
  protected void addEventEmitters(ThemedReactContext reactContext, RNCWebViewWrapper view) {
    view.getWebView().setWebViewClient(new CustomWebViewClient());
  }
}

@marco-saia-datadog
Copy link
Author

⬆️ Friendly bump :)

Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Jan 19, 2025
@believer
Copy link

This PR is still relevant. We've patched it in and custom views are working for us with it. When you have time, please have a look @Titozzz or @jamonholmgren.

@github-actions github-actions bot removed the Stale label Jan 23, 2025
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

Successfully merging this pull request may close these issues.

2 participants