I'm getting an invariant violation when trying to use the Drawer from react-navigation-drawer in my code.
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of
ProfileScreen.
Here's the return of the screen that is causing the issue to trigger:
<View>
<Drawer ref={(ref) => {this.drawer = ref}}
type="static"
tapToClose={true}
openDrawerOffset={0.35}
content={this.renderDrawer}
style={drawerStyles}>
<TouchableOpacity
style={{alignItems: "flex-end", margin: 16}}
onPress={() => this.openDrawer.bind(this)}>
<FontAwesome5 name="bars" size={24} color="161924"/>
</TouchableOpacity>
<ScrollView contentContainerStyle={styles.container}>
<View style={{marginTop: 30, alignItems: "center"}}>
<View style={styles.avatarContainer}>
<Image style={styles.avatar}
source={require('../../../assets/logo.png')}/>
</View>
<Text style={styles.name}> Juan Gómez </Text>
</View>
<View style={styles.statsContainer}>
<View style={styles.stat}>
<Text style={styles.statAmount}> 21 </Text>
<Text style={styles.statTitle}> Entregas en curso </Text>
</View>
<View style={styles.stat}>
<Text style={styles.statAmount}> 88 </Text>
<Text style={styles.statTitle}> Donaciones en curso </Text>
</View>
</View>
<SwitchSelector
buttonColor="#013773"
fontSize={16}
hasPadding
style={{ transform: [{ scaleX: .95 }, { scaleY: .95 }] }}
options={options}
initial={0}
onPress={value => console.log(`Call onPress with value: ${value}`)} />
</ScrollView>
</Drawer>
</View>
And stack trace:
This error is located at:
in RCTView (at Profile/index.js:64)
in ProfileScreen (at SceneView.tsx:98)
in StaticContainer
in StaticContainer (at SceneView.tsx:89)
in EnsureSingleNavigator (at SceneView.tsx:88)
in SceneView (at useDescriptors.tsx:125)
in RCTView (at BottomTabView.tsx:38)
in SceneContent (at BottomTabView.tsx:122)
in RCTView (at ResourceSavingScene.tsx:44)
in RCTView (at ResourceSavingScene.tsx:27)
in ResourceSavingScene (at BottomTabView.tsx:117)
in RCTView (at screens.native.js:131)
in ScreenContainer (at BottomTabView.tsx:101)
in RCTView (at BottomTabView.tsx:100)
in SafeAreaProviderCompat (at BottomTabView.tsx:99)
in BottomTabView (at createBottomTabNavigator.tsx:41)
in BottomTabNavigator (at Home/index.js:17)
in Home (at SceneView.tsx:98)
in StaticContainer
in StaticContainer (at SceneView.tsx:89)
in EnsureSingleNavigator (at SceneView.tsx:88)
in SceneView (at useDescriptors.tsx:125)
in RCTView (at CardContainer.tsx:190)
in RCTView (at CardContainer.tsx:189)
in RCTView (at Card.tsx:520)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at Card.tsx:503)
in PanGestureHandler (at Card.tsx:496)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at Card.tsx:492)
in RCTView (at Card.tsx:486)
in Card (at CardContainer.tsx:156)
in CardContainer (at CardStack.tsx:531)
in RCTView (at CardStack.tsx:106)
in MaybeScreen (at CardStack.tsx:524)
in RCTView (at CardStack.tsx:89)
in MaybeScreenContainer (at CardStack.tsx:422)
in CardStack (at StackView.tsx:384)
in KeyboardManager (at StackView.tsx:382)
in RNCSafeAreaView (at src/index.tsx:26)
in SafeAreaProvider (at SafeAreaProviderCompat.tsx:42)
in SafeAreaProviderCompat (at StackView.tsx:379)
in RCTView (at StackView.tsx:378)
in StackView (at createStackNavigator.tsx:67)
in StackNavigator (at App.js:17)
in EnsureSingleNavigator (at BaseNavigationContainer.tsx:268)
in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:39)
in ThemeProvider (at NavigationContainer.tsx:38)
in ForwardRef(NavigationContainer) (at App.js:16)
in App (at withExpoRoot.js:26)
in RootErrorBoundary (at withExpoRoot.js:25)
in ExpoRoot (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in DevAppContainer (at AppContainer.js:115)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)
renderRoot
[native code]:0
runRootCallback
[native code]:0
callFunctionReturnFlushedQueue
[native code]:0
I assume there's something I made wrong when placing the Drawer tags but I don't know what else to try.