i am new in react native please kindly help me to solve this problem: TypeError: _props.goToScreen is not a function, please help me thank in advance
Profile.js i want to click on the GotoHome Button and go to another page
export default class Profile extends Component {
_GotoHome = () => {
this.props.goToScreen('UploadProduct');
};
render() {
return (
<ListItem icon>
<Left>
<Text>List All Uploaded Product</Text>
</Left>
<Body />
<Right>
<Icon
active
name="angle-right"
type="FontAwesome"
onPress={() => this._GotoHome()}
/>
</Right>
</ListItem>
);
}
}
this is my navigation in profile page Navigation\\index.js
import {createDrawerNavigator, createAppContainer} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import {createBottomTabNavigator} from 'react-navigation-tabs';
import UploadProductScreen from './UploadProductScreen';
const ProfileStackNavigator = createStackNavigator(
{
Profile: {
screen: ProfileScreen,
},
UploadProduct: {
screen: UploadProductScreen,
},
},
{headerMode: 'none'},
);
export default createAppContainer(ProfileStackNavigator );
and here my uploadProductScreen page
import {UploadProduct} from '@container';
class UploadProductScreen extends Component {
render() {
const {navigate} = this.props.navigation;
return (
<UploadProduct
navigation={this.props.navigation}
goToScreen={(screen, EventId) => navigate(screen, {ItemId: EventId})}
/>
);
}
}
export default UploadProductScreen;
define constructor in your Profie component to use props.
constructor(props) {
super(props);
}
Also I use something like this to navigate to another screen.
this.props.navigation.navigate("UploadProduct"); // here UploadProduct is the key yo have defined in stack navigator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.