将withAuthenticator组件与react redux连接使用



我试图使用aws-amplify/ui react中的withAuthenticator HOC,但由于我也使用redux,我使用的状态部分显示为未定义,因为我必须用withAuthenticator(component(包围我的主要组件。这是代码:

export default connect(mapStateToProps, { getImages })(
withAuthenticator(About, { includeGreetings: true })
);

是否可以同时使用connect函数和withAuthenticator,或者我应该重构我的代码?

我解决了这个问题。只使用connect作为withAuthenticator中的组件变量,如下所示:

export default withAuthenticator(
connect(mapStateToProps, { getImages })(About),
{ includeGreetings: true }
);

最新更新