Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 更改映射的组件属性_Reactjs_React Native_React Redux - Fatal编程技术网

Reactjs 更改映射的组件属性

Reactjs 更改映射的组件属性,reactjs,react-native,react-redux,Reactjs,React Native,React Redux,我正在使用redux跟踪哪个屏幕用户正在使用 我有一个按钮选项卡组件: const items = [ { screen: 'home', title: 'home', icon: 'apps', route: 'Home' }] renderTab = () => { return items.map((tabBarItem, index) => { return ( <Tab key={index}

我正在使用redux跟踪哪个屏幕用户正在使用

我有一个按钮选项卡组件:

const items = [
{
  screen: 'home',
  title: 'home',
  icon: 'apps',
  route: 'Home'
}]

renderTab = () => {
    return items.map((tabBarItem, index) => {
      return (
        <Tab
          key={index}
          title={tabBarItem.title}
          icon={tabBarItem.icon}
          route={tabBarItem.route}
        />
      );
    });
  };
Tab.js:

class Tab extends Component {
  render() {
    return (
      <Button onPress={() => navigation.navigate(route)}>
        <Icon
          style={selected ? deviceStyle.tabSelectedColor : deviceStyle.tabDefaultColor}
          type="Ionicons"
          name={icon}
        />
        <Text style={selected ? deviceStyle.tabSelectedColor : deviceStyle.tabDefaultColor}>
          {title}
        </Text>
      </Button>
    );
  }
}
类选项卡扩展组件{
render(){
返回(
导航。导航(路线)}>
{title}
);
}
}
然后我从另一个组件调用它:

const items = [
{
  screen: 'home',
  title: 'home',
  icon: 'apps',
  route: 'Home'
}]

renderTab = () => {
    return items.map((tabBarItem, index) => {
      return (
        <Tab
          key={index}
          title={tabBarItem.title}
          icon={tabBarItem.icon}
          route={tabBarItem.route}
        />
      );
    });
  };
const项=[
{
屏幕:“主页”,
标题:"家",,
图标:“应用程序”,
路线:“家”
}]
renderTab=()=>{
返回项目.map((选项卡项,索引)=>{
返回(
);
});
};

现在,当用户更改屏幕时,如何更改选项卡组件中的
选定道具?

有两种方法可以实现这一点。 1) 单击/onpress您的
选项卡
可以发送一个操作,该操作将更新用户的当前屏幕,正如当前一样,您正在该页面上导航用户。 2) 加载屏幕时,单击/按tab键后将加载该屏幕


您只需要一个操作来更新用户的当前屏幕

您在哪里设置“选定”属性?它应该从renderTab传递。您是否使用react router dom?react导航