gusparis / react-native-month-year-picker

React Native Month Picker component for iOS & Android
MIT License
106 stars 74 forks source link

Model opens up atuomatically when app come from background state to foreground state #28

Closed tirath2 closed 4 years ago

tirath2 commented 4 years ago

i have just copied your example code and it works fine when app is in foreground but when we put the app in background and open it up again that time the picker opens up automatically.please refer to the video attacked bellow. versions

"react": "16.13.1", "react-native": "^0.63.1", "react-native-month-year-picker": "^1.3.2",

my code

` /**

import Navigator from "@navigation/Router"; import rootReducer from "@redux/RootReducer"; import { ThemeContextProvider } from "@theme/ThemeHelper"; // import React from "react"; import Apps from "./src/App"; import { name as appName } from "./app.json"; import { AppRegistry } from "react-native";

// const App = () => ( // // // // );

AppRegistry.registerComponent(appName, () => App);

import React, { useState, useCallback } from "react"; import { SafeAreaView, StyleSheet, Text, TouchableOpacity } from "react-native"; import moment from "moment";

import MonthPicker from "react-native-month-year-picker";

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#dfe6e9" }, button: { justifyContent: "center", alignItems: "center", backgroundColor: "#b2bec3", borderRadius: 4, padding: 10 }, buttonText: { color: "#2d3436" } });

const DEFAULT_FORMAT = "MM-YYYY"; const DEFAULT_OUTPUT_FORMAT = "MMM-YYYY";

const App = () => { const [date, setDate] = useState(new Date()); const [show, setShow] = useState(false);

const showPicker = useCallback((value) => setShow(value), []);

const onValueChange = useCallback( (event, newDate) => { const selectedDate = newDate || date;

  showPicker(false);
  setDate(selectedDate);
},
[date, showPicker]

);

return (

Month Year Picker Example {moment(date, DEFAULT_FORMAT).format(DEFAULT_OUTPUT_FORMAT)} showPicker(true)} style={styles.button}> OPEN {show && ( )}

); };

`

ezgif com-video-to-gif

gusparis commented 4 years ago

Thank you for using the library. Bug Fixed by #29.