小编Dim*_*lko的帖子

React Navigation onPress 函数在自己的 tabBarButton 中?

我是初学者,我需要为 tabBarButton 制作组件,我成功了。

问题是导航现在不起作用,因为我不知道如何编写 onPress 函数以使其起作用!

有人可以帮我解决这个问题吗?

这是我的组件,我在我的Tab.Navigator

import React from 'react';
import {StyleSheet, TouchableOpacity, View} from 'react-native';
import Text from '../Text/Text';

interface Props {}

const NavBottomButton: React.FC<Props> = (props) => {
  const {children} = props;

  return (
    <TouchableOpacity onPress={() => {}} style={styles.navButton}>
      <View>
        <Text>{children}</Text>
      </View>
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  navButton: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default NavBottomButton;
Run Code Online (Sandbox Code Playgroud)

这是我使用组件的方式:

<Tab.Navigator
  tabBarOptions={someStyles}>
  <Tab.Screen
    name="Matches"
    component={Matches}
    options={{
      tabBarButton: (props) => (
        <NavBottomButton …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

4
推荐指数
1
解决办法
6095
查看次数

根据当前 URL 更改 Link 的 className,React

我有带有 的侧边栏组件Links,并且我需要Link在打开特定 URL 时更改颜色。

React 中最好的解决方案是什么?

reactjs react-router-dom

2
推荐指数
1
解决办法
471
查看次数