JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q62806F
  • License MIT

A cross platform pure js modal implimentaion

Package Exports

  • @idiosync/react-native-modal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@idiosync/react-native-modal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM Version

Telescope

A cross platform, pure js modal implimentaion - by

  • Uses pure JS
  • Does not use the additional native layer used by react-native's implimentation
  • Fixes Android bugs assosiated with touch events
  • Uses hooks, rather than adding things to a component's render that aren't displayed
  • Has four animation types

Installation

yarn:

$ yarn add @idiosync/react-native-modal

npm:

$ npm i @idiosync/react-native-modal

Basic Usage

The simplist implimentaion uses the useModal hook and controls visability at the component where the hook is being used

import { useModal } from "@idiosync/react-native-modal"

const SomeComponent = () => {
  const [modalIsVisible, setModalIsVisible] = useState(false)

  // this config is optional
  const optioins = {
    onBackgroundPress: () => setModalIsVisible(false),
    animationTypeIn: AnimationType.SLIDE_TOP,
    animationTypeOut: AnimationType.SLIDE_BOTTOM,
  }

  useModal(
    () => <MyModal onClose={() => setModalIsVisible(false)} />,
    modalIsVisible
    optioins
  )

  return (
    <SomeOtherComponent onShowModal={() => setModalIsVisible(true) />
  )
}