react-native-modals icon indicating copy to clipboard operation
react-native-modals copied to clipboard

Use the built-in Modal component from React Native

Open LinusU opened this issue 6 years ago • 4 comments

Fixes #150

ping @jeppeArchidraw, @shanekoss feel free to try this out and see if it fixes your problem:

npm install LinusU/react-native-popup-dialog#rn-modal

or

yarn add LinusU/react-native-popup-dialog#rn-modal

LinusU avatar Jul 19 '19 10:07 LinusU

friendly ping @jacklam718 ☺️

LinusU avatar Jul 22 '19 19:07 LinusU

friendly ping @jacklam718 ☺️

Our app isn't suffering from #150 without this, would be great to get this merged and a new release cut 👍

LinusU avatar Jul 30 '19 10:07 LinusU

@LinusU Very sorry for late reply and Thanks for your pull request. I use react-native-root-siblings instead of built-in Modal component because I want to support multi dialogs but the built-in Modal component doesn't support multiple modals FYI: https://github.com/facebook/react-native/issues/3445.

jacklam718 avatar Jul 31 '19 12:07 jacklam718

No worries!

From reading around the links from the issue, I think that this has actually been solved in a later version of react-native. To be absolutely sure I tested it, and it seems to work great:

File (2)

import React, { useState } from 'react'
import { Button, SafeAreaView, Text } from 'react-native'

import Dialog from 'react-native-popup-dialog'

const SecondPopup = ({ onTouchOutside, visible }) => {
  return (
    <Dialog onTouchOutside={onTouchOutside} visible={visible}>
      <Text>Second popup!</Text>
    </Dialog>
  )
}

const FirstPopup = ({ onTouchOutside, visible }) => {
  const [showPopup, setShowPopup] = useState(false)

  return (
    <Dialog onTouchOutside={onTouchOutside} visible={visible}>
      <Text>Hello, World!</Text>
      <Text>This is the first popup</Text>
      <Button title='Second' onPress={() => setShowPopup(true)} />

      <SecondPopup onTouchOutside={() => setShowPopup(false)} visible={showPopup} />
    </Dialog>
  )
}

const App = () => {
  const [showPopup, setShowPopup] = useState(false)

  return (
    <SafeAreaView>
      <Button title='Open first' onPress={() => setShowPopup(true)} />

      <FirstPopup onTouchOutside={() => setShowPopup(false)} visible={showPopup} />
    </SafeAreaView>
  )
}

export default App

Feel free to try it out yourself! ☺️

edit: This was an empty React Native project, with this branch installed (npm add LinusU/react-native-popup-dialog#rn-modal) and the code above pasted into App.js

LinusU avatar Aug 02 '19 16:08 LinusU