React Native Elements Overlay: Troubleshooting Webview Functionality

I've implemented react-native-element for the components in my app and I'm using Overlay to display modals. However, I encountered an issue with displaying a WebView within one of the modals.

export const Modal = ({ visible, showCrossBtn, setModalVisible, backgroundColor, children }) => {

    return (
        <Overlay
            isVisible={visible}
            fullScreen={false}
            height="auto"
            overlayBackgroundColor={backgroundColor}
            overlayStyle={styles.overlay}
            onBackdropPress={() => setModalVisible(false)}>
            <View style={styles.dialogBox}>
                {
                    showCrossBtn && <TouchableOpacity style={[styles.crossPosition, styles.crossStyling]} onPress={() => setModalVisible(false)}>
                        <Icon name="cross" type="entypo" color={colors.gray} size={30} />
                    </TouchableOpacity>
                }

                <View style={styles.body}>
                    {children}
                </View>
            </View>
        </Overlay>
    )
}

The scenario in my main component looks like this:

export const Home = ({ }) => {
  return (
    ....
    ....
    <Modal
      visible={this.props.visible}
      setModalVisible={this.props.setModalVisible}
      backgroundColor={colors.lightgray}
      showCrossBtn={false}
      >
      <WebView
                style={[{ height: 20 }, styles.webView]}
                originWhitelist={['*']}
                ref={e => webview = e}
                source={{ html: '<p>HELLO WORLD</p>'}} />
    </Modal>

  )
}

Answer №1

When incorporating WebView into modals, it can present challenges with height and width adjustments.

To address this issue, I have developed a solution using the Snack platform along with the react-native-elements library's Overlay component and WebView. I streamlined the code by removing any unnecessary elements for simplicity.

You can test the snack on either an iOS or Android simulator, or run it on your physical device through the Expo app.

Access the Snack here:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The JSON data is riddled with numerous key/value pairs that are absent

When using Axios to load a static JSON file from the React application server, I noticed that many key/value pairs are missing after reading the files. The specific JSON file in question is asset-manifest.json, which contains all the assets (media, css, j ...

The dropdown menu for `react-google-autocomplete` does not appear when used with an MUI

Currently, I am attempting to create an Address form dialog using the Google Places API. The issue arises when I utilize the react-google-autocomplete's usePlacesWidget along with MUI TextField in a Material UI Dialog. The dropdown menu for Google Pl ...

Router DOM in conjunction with Next.js

I am attempting to extract the output of the code in navigation, but unfortunately it is generating a dreadful error: Unhandled Runtime Error Error: You cannot render a <Router> inside another <Router>. You should never have more than one in ...

material-ui DropDown with an image displayed for the selected value

Can someone help me figure out how to display an image in my material-ui dropdown menu? I'm currently using version 0.19.1 and have written the following code: <DropDownMenu autoWidth style={{ width: 500, marginBottom: 30 }} underlin ...

Is it possible to determine the specific type of props being passed from a parent element in TypeScript?

Currently, I am working on a mobile app using TypeScript along with React Native. In order to maintain the scroll position of the previous screen, I have created a variable and used useRef() to manage the scroll functionality. I am facing an issue regardi ...

Tips on sending various properties to makeStyles() using TypeScript

After learning how to pass 1 prop to makeStyle() from a resource, I decided to try passing in 2 props for my project. However, I encountered an error stating cannot find name 'props'. Any assistance on this issue would be greatly appreciated! con ...

The useStyles function does not automatically update properties in response to changes in variables

I have encountered an issue where the style of a component is not changing based on a boolean state change until I refresh the page. Here's what I'm doing: Within my parent App component, I have the following code: import React from "react"; imp ...

reveal.js: Upon a fresh installation, an error has been encountered: ReferenceError - 'navigator'

Currently, I am attempting to integrate reveal.js into my React.js/Next.js website using the instructions provided at However, upon implementation, I encountered the following error: Server Error ReferenceError: navigator is not defined This error occurr ...

Executing commands in the package.json file

Currently navigating a sizable codebase, my aim is to execute scripts from the package.json file exemplified below: https://i.stack.imgur.com/a1Rvu.png Whenever the command "npm start" is initiated, it defaults to the dev script resulting in an ...

A guide to implementing react-hook-form in conjunction with form actions

Having trouble with this code as it's not performing validation upon submission? The login process is coded here using Zod for validation and React Hook Form for managing the form. However, the validation seems to be skipping, leading to a direct call ...

Creating a return type in TypeScript for a React Higher Order Component that is compatible with a

Currently utilizing React Native paired with TypeScript. Developed a HOC that functions as a decorator to add a badge to components: import React, { Component, ComponentClass, ReactNode } from "react"; import { Badge, BadgeProps } from "../Badge"; functi ...

The video.play() function encountered an unhandled rejection with a (notallowederror) on IOS

Using peer.js to stream video on a React app addVideoStream(videoElement: HTMLVideoElement, stream: MediaStream) { videoElement.srcObject = stream videoElement?.addEventListener('loadedmetadata', () => { videoElement.play() ...

`Execution terminated: npm start unable to run properly due to error at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:135:

As a newcomer to the React/Node.js realm, I've been struggling for a few days. I recently installed node-v13.50.0-x64 and executed the following commands: npm install expo-cli --global expo init myproject After navigating to the [myproject] directo ...

Interacting and invoking functions in ReactJS through event handling

Whenever the student button is clicked, it should call the function that I have named the other component, but I am encountering an error. How can I successfully call the other component on click? import React from 'react'; //import s from &a ...

Numerous stylesheets being imported

import styles from './auth-input.module.css' Incorporating this in my authInput component, I utilize it several times throughout the project. Would it be more efficient to import the CSS only once, even if I use the component multiple times? ...

Is there a way to customize the font size of Material UI Autocomplete?

I'm currently trying to customize the Material UI Autocomplete component with my own CSS. Specifically, I aim to adjust the font size of the input field. Below is my current implementation: <Autocomplete style={{ width: 200, height: 60, ...

How can I modify the border color of a Material Ui TextField component?

I've been struggling to figure out how to customize the color of the TextField border. I want to change it from the default grey to black. Below is a simplified version of my UpdatePage.js file: const useStyles = makeStyles(() => ({ updatePage ...

Steps for embedding the code into your website

I'm facing an issue with integrating a .jsx file into my website. I tried testing it on a single-page demo site, but nothing is showing up. Can someone guide me through the steps to successfully integrate it onto my site? I've also attached the . ...

Create a stunning MUI App bar with a blurred effect below a fixed Navbar

Is there a method to apply a blur effect to the background of my material-ui AppBar component, creating a visually appealing overlay below the fixed navbar? I have experimented with using filter: blur(0) but it does not achieve the desired result. I am lo ...

Toggling visibility in React Native by pressing a button

i have a toolbar in my react-native app that looks like this: https://i.stack.imgur.com/Msu4t.png Whenever I click on the search icon, I want to display an input text field like this: https://i.stack.imgur.com/HPwTB.png I've tried several examples ...