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

Tapping on Picker element crashes app #320

Open
peterchibunna opened this issue Apr 12, 2021 · 3 comments
Open

Tapping on Picker element crashes app #320

peterchibunna opened this issue Apr 12, 2021 · 3 comments

Comments

@peterchibunna
Copy link

peterchibunna commented Apr 12, 2021

Describe the bug
If a Picker element is contained within Modalize element, tapping on the Picker.Item crashes the App; However tapping on the arrow of the Picker allows you to successfully choose an item. It is the tapping on the picker directly that crashes the App, without any exception trace.

Code:

import React, {createRef, useEffect, useRef, useState} from 'react';
import {StyleSheet, View, Dimensions, ScrollView} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {Button, Colors, Divider, FAB, HelperText, IconButton, Text, Title} from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialIcons';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import FontAwesome5Brands from 'react-native-vector-icons/FontAwesome5';
import {bindActionCreators} from 'redux';
import * as Actions from '../actions';
import {connect} from 'react-redux';
import {remove, find} from 'lodash';
import {theme} from '../theme';
import {Modalize} from 'react-native-modalize';
import {Picker} from '@react-native-picker/picker';

const Home = ({navigation, ...props}) => {
	//const modalRef = useRef<Modalize>(null);
	const modalRef = createRef();
        const [items, setItems] = useState([
		{name: 'Shoe', id: 1},
		{name: 'Belt', id: 2},
		{name: 'Trouser', id: 3},
		{name: 'Sandals', id: 3},
		{name: 'Women\'s Shoes', id: 3},
		{name: 'Long Dress', id: 3},
	]);
	const [item, setItem] = useState(null);
         return (
    <Modalize onClosed={onClose} snapPoint={height * (2 / 3)} tapGestureEnabled={false} adjustToContentHeight={true} ref={modalRef}>
    
          <View>
	          <Picker
		          onValueChange={(itemValue, itemIndex) => {
			          setItem(() => {
				          return find(items, {'id': itemValue});
			          });
		          }}
		          selectedValue={item?.id}
		          style={{height: 45, alignItems: 'center', color: '#fff'}}>
		          <Picker.Item label={'Choose item'} value={null}/>
		          {items.map(({id, name}, idx) => (
			          <Picker.Item label={name.toString()} value={id}/>
		          ))}
	          </Picker>
          </View>
    </Modalize>
);

Dependencies:

  • "react-native-modalize": "^2.0.8",
  • "react-native": "0.64.0"
  • "react-native-gesture-handler": "^1.10.3",
  • "@react-native-picker/picker": "^1.12.0"

Snack
https://snack.expo.io/OfUJMLM5x

@peterchibunna
Copy link
Author

Further info, It doesn't crash in expo, but on real device (tested on Android 6 and 7)

@peterchibunna
Copy link
Author

I think this is related to react-native-picker/picker#237

@feriferdinan
Copy link

got same error

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

2 participants