问题
I'm trying to figure out how to pass props to the 'Camera' component but getting a syntax error when i try
component= { Camera doSomething={this.doSomething}}
cant seem to find documentation to help on this one. Im sure its simple if you know how - hoping someone can assist.
my code
import React, { Component } from 'react';
import Camera from './camera'
import VideoComponent from './video'
import AudioComponent from './audio'
import File from './file'
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import { MaterialCommunityIcons } from 'react-native-vector-icons';
const CaptureNav = createMaterialBottomTabNavigator();
class Capture extends Component {
render(){
return (
<CaptureNav.Navigator >
<CaptureNav.Screen
name="Camera"
component= {Camera}
options={{
tabBarIcon : () => (
<MaterialCommunityIcons name='camera' color={'black'} size={26} />
)
}}
/>
<CaptureNav.Screen
name="Video"
component= {VideoComponent}
/>
<CaptureNav.Screen
name="Audio"
component= {AudioComponent}
/>
<CaptureNav.Screen
name="File"
component= {File}
/>
</CaptureNav.Navigator>
)
}
}
export default Capture
回答1:
<Stack.Screen name="Home">
{props => <HomeScreen {...props} extraData={someData} />}
</Stack.Screen>
check this
来源:https://stackoverflow.com/questions/60664242/passing-props-to-child-components-with-a-react-navigation