Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visible modal is slow #277

Open
niloofarSadeghi76 opened this issue Jun 2, 2021 · 3 comments
Open

visible modal is slow #277

niloofarSadeghi76 opened this issue Jun 2, 2021 · 3 comments

Comments

@niloofarSadeghi76
Copy link

hello, recently i add this package to my react native project, it takes 10 second or more visible on android.

React Native version: 0.61.5
react-native-modals version: 0.22.3

i used these two properties too:
modalAnimation={new SlideAnimation({ slideFrom: 'bottom' })}
useNativeDriver

@harsimrandev
Copy link

Facing this same issue. Do we have solution yet ?

@niloofarSadeghi76
Copy link
Author

Facing this same issue. Do we have solution yet ?

Not yet :|

@MAsad-Nawaz
Copy link

Here is the sample code. @niloofarSadeghi76 also check this issue on #30

import React, { useState } from "react";
import { Button, Text, View, StyleSheet } from "react-native";
import Modal from "react-native-modal";

function MyModal(props) {
  const headerComponent = (
    <View style={{ margin: 30 }}>
      <Text style={{ fontSize: 30, color: "white", textAlign: "center" }}>
        Here
      </Text>
    </View>
  );

  const customBackdrop = (
    <View style={styles.modalBackground}>
      <View
        style={[styles.modalBackgroundContent, { backgroundColor: "blue" }]}
      >
        {headerComponent}
      </View>
    </View>
  );

  return (
    <Modal
      style={{ margin: 0, marginTop: 100 }}
      backdropOpacity={1}
      customBackdrop={customBackdrop}
      swipeDirection={"down"}
      onSwipeComplete={props.onRequestClose}
      isVisible={props.isVisible}
      hideModalContentWhileAnimating={true}
    >
      <View style={styles.modalView}>
        <View style={styles.formView}>{props.children}</View>
      </View>
    </Modal>
  );
}

function ModalTester() {
  const [isModalVisible, setModalVisible] = useState(false);

  const toggleModal = () => {
    setModalVisible(!isModalVisible);
  };

  return (
    <View style={{ flex: 1 }}>
      <Button title="Show modal" onPress={toggleModal} />

      <MyModal isVisible={isModalVisible} onRequestClose={toggleModal}>
        <View style={{ flex: 1 }}>
          <Text>Hello!</Text>

          <Button title="Hide modal" onPress={toggleModal} />
        </View>
      </MyModal>
    </View>
  );
}

const styles = StyleSheet.create({
  closeButton: {
    paddingTop: 5,
    paddingLeft: 5
  },
  modalView: {
    flex: 1,
    justifyContent: "flex-end",
    alignItems: "center"
  },
  modalBackground: {
    flex: 1
  },
  modalBackgroundContent: {
    flex: 1
  },
  formView: {
    flex: 1,
    width: "100%",
    borderTopRightRadius: 10,
    borderTopLeftRadius: 10,
    overflow: "hidden",
    backgroundColor: "white"
  }
});

export default class App extends React.Component {
  render() {
    return <ModalTester />;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants