Skip to content

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

Closed
marco-saia-datadog wants to merge 1 commit intoreact-native-webview:masterfrom
marco-saia-datadog:master
Closed

[ANDROID] Allow using a custom RNCWebView in New Architecture#3586
marco-saia-datadog wants to merge 1 commit intoreact-native-webview:masterfrom
marco-saia-datadog:master

Conversation

@marco-saia-datadog
Copy link
Copy Markdown

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
Copy Markdown
Author

⬆️ Friendly bump :)

@github-actions
Copy link
Copy Markdown

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
Copy Markdown

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
@github-actions
Copy link
Copy Markdown

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 Mar 24, 2025
@marco-saia-datadog
Copy link
Copy Markdown
Author

👋 @Titozzz @jamonholmgren

Could you take a look into this, please?

@github-actions github-actions bot removed the Stale label Mar 25, 2025
@github-actions
Copy link
Copy Markdown

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 Jun 18, 2025
@github-actions github-actions bot closed this Jun 25, 2025
@believer
Copy link
Copy Markdown

This is still an issue in our project. Any chance of reopening this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants