Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Passing react-native-paper-dropdown multiSelect as a prop throws a "Render Error"

$
0
0

In the CustomDropdown file, adding the multiSelect prop crashes the React-Native application built with expo (on a phsyical iPhone SE 2020 device).

CustomDropdown.tsx:

const CustomDropdown = ({    name,    list,    control,    rules = {},    multiSelect = false}) => {    const [showDropDown, setShowDropDown] = useState(false);    return (<Controller            name={name}            control={control}            rules={rules}            render={({ field: {value, onChange} }) => <View style={{ marginTop: 25, width: "60%", marginLeft: "auto", marginRight: "auto" }}><DropDown                        theme={DefaultTheme}                        label={name}                        mode={"outlined"}                        visible={showDropDown}                        showDropDown={() => setShowDropDown(true)}                        onDismiss={() => setShowDropDown(false)}                        value={value}                        setValue={onChange}                        list={list}                        multiSelect={multiSelect}                    /></View>            }        />    )}

The code that calls the component:

<CustomDropdown    name="Category"    control={control}    list={EventCategories}    multiSelect={true}/>

Note: without the multiSelect prop passed down to CustomDropdown, the Dropdown component works fine without errors.

The error message:

TypeError: undefined is not an object (evaluating 'value.indexOf')This error is located at:    in Unknown    in RCTView (created by View)    in View    in Unknown (created by CustomDropdown)    in CustomDropdown (created by NewEventForm)    in RCTView (created by View)    in View (created by NewEventForm)    in NewEventForm (created by NewEvent)    in RCTScrollContentView (created by ScrollView)    in RCTScrollView (created by ScrollView)    in ScrollView (created by ScrollView)    in ScrollView (created by NewEvent)    in NewEvent (created by SceneView)    in StaticContainer    in EnsureSingleNavigator (created by SceneView)    in SceneView (created by CardContainer)    in RCTView (created by View)    in View (created by CardContainer)    in RCTView (created by View)    in View (created by CardContainer)    in RCTView (created by View)    in View    in CardSheet (created by Card)    in RCTView (created by View)    in View (created by AnimatedComponent)    in AnimatedComponent    in AnimatedComponentWrapper (created by PanGestureHandler)    in PanGestureHandler (created by PanGestureHandler)    in PanGestureHandler (created by Card)    in RCTView (created by View)    in View (created by AnimatedComponent)    in AnimatedComponent    in AnimatedComponentWrapper (created by Card)    in RCTView (created by View)    in View (created by Card)    in Card (created by CardContainer)    in CardContainer (created by CardStack)    in RNSScreen (created by AnimatedComponent)    in AnimatedComponent    in AnimatedComponentWrapper (created by Screen)    in MaybeFreeze (created by Screen)    in Screen (created by MaybeScreen)    in MaybeScreen (created by CardStack)    in RNSScreenContainer (created by ScreenContainer)    in ScreenContainer (created by MaybeScreenContainer)    in MaybeScreenContainer (created by CardStack)    in RCTView (created by View)    in View (created by Background)    in Background (created by CardStack)    in CardStack (created by HeaderShownContext)    in RNCSafeAreaProvider (created by SafeAreaProvider)    in SafeAreaProvider (created by SafeAreaInsetsContext)    in SafeAreaProviderCompat (created by StackView)    in RCTView (created by View)    in View (created by GestureHandlerRootView)    in GestureHandlerRootView (created by StackView)    in StackView (created by StackNavigator)    in Unknown (created by StackNavigator)    in StackNavigator (created by App)    in EnsureSingleNavigator    in BaseNavigationContainer    in ThemeProvider    in NavigationContainerInner (created by App)    in ThemeProvider (created by Provider)    in RCTView (created by View)    in View (created by Portal.Host)    in Portal.Host (created by Provider)    in Provider (created by App)    in App (created by ExpoRoot)    in ExpoRoot    in RCTView (created by View)    in View (created by AppContainer)    in DevAppContainer (created by AppContainer)    in RCTView (created by View)    in View (created by AppContainer)    in AppContainer    in main(RootComponent)at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportExceptionat node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleExceptionat node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:52:4 in showErrorDialogat node_modules/react-native/Libraries/ReactNative/renderApplication.js:76:4 in renderApplicationat node_modules/react-native/Libraries/ReactNative/AppRegistry.js:119:25 in runnables.appKey.runat node_modules/react-native/Libraries/ReactNative/AppRegistry.js:213:4 in runApplication

Is there something evident wrong with the presented code?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>