首页 > 解决方案 > 如何在 React 类组件中使用 Redux 与多个 React 提供程序连接?

问题描述

在使用 Redux 的 React 组件中,除了 Redux connect() 之外,我还想使用 withCookies 和 withAuth0 提供程序。

import { withCookies } from 'react-cookie';
import { withAuth0 } from '@auth0/auth0-react';

class TopBarRedux extends React.Component<any, any>{
...

export const TopBar = withCookies(
  withAuth0(
    connect(
      mapStateToProps,
      mapDispatchToProps,
    )(TopBarRedux)
  )
)

但是,当使用该组件时

<TopBar />

componentDidMount() 被调用,但 componentDidUpdate() 从未被调用。export const 的语法或顺序是否不正确?

标签: reduxreact-redux

解决方案


推荐阅读