简体   繁体   中英

Using withAuthenticator component with connect from react-redux

I'm trying to use the withAuthenticator HOC from aws-amplify/ui-react but since I'm using redux as well I'm getting the parts of the state that I'm using showing up as undefined because I have to surround my main component with withAuthenticator(Component). Here's the code:

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

Is it possible to use the connect function and the withAuthenticator at the same time or should I refactor my code?

I solved it. Just used the connect as the component variable in withAuthenticator, like this:

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM