Issue with React-Native 0.68.2 Modals not functioning on iOS platform

After upgrading my react native application to react version 17.0.1 and react-native 0.68.2, the modals are no longer visible on my iOS application. I have been using the react-native-modal: "^13.0.1" library to create these modals.

In an attempt to troubleshoot the issue, I replaced the sample modal code from react-native-modal-example with my existing code, but unfortunately, the problem persists despite this change.

A bug similar to the one I am experiencing has been reported here.

As a workaround, I tried using the modal provided by react-native instead of react-native-modal: "^13.0.1", but the issue remains unresolved.

Could someone provide guidance or a solution for this particular matter?

Below is a snippet of my code:


import React, {useState} from 'react';
import {Image, View, Text, TouchableOpacity, Alert, Pressable, StyleSheet} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import Modal from 'react-native-modal'

const login = props => {

const [modalVisible, setModalVisible] = useState(false);

return (
<SafeAreaView style={styles1.centeredView}>
<Modal isVisible={true}>
<View style={styles1.centeredView}>
<View style={styles1.modalView}>
<Text style={styles1.modalText}>Hello World!</Text>
<Pressable
style={[styles1.button, styles1.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}>
<Text style={styles1.textStyle}>Hide Modal</Text>
</Pressable>
</View>
</View>
</Modal>

<TouchableOpacity
style={[styles1.button, styles1.buttonOpen]}
onPress={() => setModalVisible(true)}>
<Text style={styles1.textStyle}>Show Modal</Text>
</TouchableOpacity>
</SafeAreaView>
);
};

const styles1 = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
margin: 20,
backgroundColor: "white",
borderRadius: 20,
padding: 35,
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2
},
buttonOpen: {
backgroundColor: "#F194FF",
},
buttonClose: {
backgroundColor: "#2196F3",
},
textStyle: {
color: "white",
fontWeight: "bold",
textAlign: "center"
},
modalText: {
marginBottom: 15,
textAlign: "center"
}
});

export default (login);

Answer №1

Success! It works perfectly.

https://i.sstatic.net/Ab7FZ.png

import React, { useState } from "react";
import {
  Modal,
  View,
  Text,
  TouchableOpacity,
  Alert,
  Pressable,
  StyleSheet,
  SafeAreaView
} from "react-native";

const Demo = props => {
  const [visibleModal, setModalVisibility] = useState(false);

  return (
    <SafeAreaView style={design.centeredView}>
      <Modal isVisible={true}>
        <View style={design.centeredView}>
          <View style={design.modalView}>
            <Text style={design.modalText}>Greetings world!</Text>
            <Pressable
              style={[design.button, design.buttonClose]}
              onPress={() => setModalVisibility(!visibleModal)}
            >
              <Text style={design.textStyle}>Conceal Modal</Text>
            </Pressable>
          </View>
        </View>
      </Modal>

      <TouchableOpacity
        style={[design.button, design.buttonOpen]}
        onPress={() => setModalVisibility(true)}
      >
        <Text style={design.textStyle}>Reveal Modal</Text>
      </TouchableOpacity>
    </SafeAreaView>
  );
};

export default Demo;

const design = StyleSheet.create({
  centeredView: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    marginTop: 22
  },
  modalView: {
    margin: 20,
    backgroundColor: "white",
    borderRadius: 20,
    padding: 35,
    alignItems: "center",
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2
    },
    shadowOpacity: 0.25,
    shadowRadius: 4,
    elevation: 5
  },
  button: {
    borderRadius: 20,
    padding: 10,
    elevation: 2
  },
  buttonOpen: {
    backgroundColor: "#F194FF"
  },
  buttonClose: {
    backgroundColor: "#2196F3"
  },
  textStyle: {
    color: "white",
    fontWeight: "bold",
    textAlign: "center"
  },
  modalText: {
    marginBottom: 15,
    textAlign: "center"
  }
});

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

Any tips on getting my Squarespace Cover page video to resize properly?

I recently implemented a cover page with a looping video background on my Squarespace site. The video used to automatically resize to fit the browser window perfectly, but now it seems to be playing at its full resolution. I don't have much experience ...

Is there a way to adjust the size of the canvas element in HTML without compromising quality or resorting to zooming?

I'm currently working on a basic modeling application for the web. The main component of my app is a canvas element that I'm trying to size correctly. However, when I set the height and width using CSS, it scales the entire canvas and compromises ...

The UIPopoverPresentationController's barButtonItem functionality appears to be malfunctioning and is being overlooked

Encountering an issue with displaying a UIAlertController of type UIActionSheet on iPad. Aware that iPads require more information for popover display, but facing strange challenges. Testing for iOS 13 compatibility issues in my app reveals that the old w ...

Implementing Vue.js functionality to dynamically add or remove values from an array based on the state of a checkbox

I recently embarked on my journey to learn vue.js and I've encountered a challenging issue. I have dynamic data that I render using a 'v-for' loop. Additionally, I have an empty array where I need to store checked checkbox data and remove it ...

JavaScript (Automatic) for a full-screen webpage display

I'm having trouble creating a webpage and setting it to fullscreen mode. Here's the JavaScript code I have: var elem = document.getElementById("fulscreen"); var fs = document.getElementById("body"); elem.onclick = function() { req = fs.webk ...

Having trouble selecting a radio button in React JS because it's marked as read-only due to the check attribute

In my scenario, I have a child component with radio buttons. The questions and radio buttons are populated based on the data, with each set consisting of one "yes" and one "no" option. I am attempting to automatically check all radio buttons that have a v ...

ng-repeat table grouping by date

How can I utilize *ngFor to generate an HTML table grouped by date in columns? Here is an example of a JSON List: [{ "id": "700", "FamilyDesc": "MERCEDES", "model": "Mercedes-BenzClasse A", " ...

Generating an HTML table that adjusts its size based on the paper dimensions chosen by the user

I am facing a challenge with my html table and print option on a webpage. Currently, users can easily print the table on an A4 page by default using the JavaScript print function. The table fits perfectly on the full size of the A4 page. However, I now h ...

Reactjs event handler binding to functions

Can you explain the reason behind having to bind an object null to the function? add(text) { this.setState(prevState=> ({ notes: [ ...prevState.notes, { id: this.nextId(), note: text ...

Can an unlimited number of renderers be activated in THREE.js?

To avoid getting sidetracked, let me provide some context. I am looking to display numerous waveforms stacked on top of each other using the same time axis in THREE.js. These waveforms are essentially THREE.Line objects and I am working on implementing zoo ...

Best practices for executing an asynchronous forEachOf function within a waterfall function

I've been working with the async library in express js and I'm encountering an issue when using two of the methods alongside callbacks. The variable result3 prints perfectly at the end of the waterfall within its scope. However, when attempting t ...

Error detected in JSON parsing

I keep encountering a json parse error Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 2.) This indicates that there is an issue in the jSON response. What's stra ...

Locate the position of a SKSpriteNode within an Array using Swift

Struggling to retrieve the index of nodes in an array using... let menuArray = [firstNode, secondNode, thirdNode] for arrayNode in menuArray { let index = menuArray.index(of:arrayNode) } Encountering the error message "Cannot invoke "index" with ...

Ways to invoke a function within a React Material-UI component

Currently, I am in the process of setting up a chat system that allows users to add emojis. To achieve this feature, I have devised a function that produces a component containing both text and an image. Here is the function I have implemented: test: fu ...

The ng-submit() directive in Angular does not trigger submission when the "Enter" key is pressed in a text field

I have created a basic form using Angular where I want the ng-click function (updateMsg({name: name,room: room})) to be triggered when the user enters a value and then presses enter key. Unfortunately, the current code does not work as expected. The funct ...

The presence of parentheses in a JQuery selector

My database contains divs with ids that sometimes have parentheses in them. This is causing issues with my JQuery selector. How can I resolve this problem? Let me provide an example to illustrate: https://jsfiddle.net/2uL7s3ts/1/ var element = 'hel ...

"Upon triggering an event in AngularJS, the data attribute transitions to a state of truth

Here is the input I am using: <input type="checkbox" ng-model="area.id" data-id="{{area.id}}"/> Above this, there is some action with ng-click functionality. My goal is to gather all selected checkboxes' ids. However, after checking them, the ...

Troubleshooting unexpected issues with dynamically updating HTML using innerHTML

Need help with a renderWorkoutUpdated function that replaces specific workout records with updated values. _renderWorkoutUpdated(currentWorkout) { let html = `<li class="workout workout--${currentWorkout.type}" data-id="${ curre ...

What is the best way to retrieve a button's value upon clicking and display it in a React component?

Picture a calculator display. Each button press should output the value of that button once, and if pressed multiple times, the value should be displayed accordingly. import { useState } from "react"; function App() { const [data, setData] = ...

Unable to save Ajax data in session array

Currently, I am developing a cart system using jquery, ajax, and php. The issue I am facing is that the text within the HTML elements is not being added to the session array. Below is the ajax code I am using: $(document).ready(function(){ $("#car ...