How to combine react-redux connect() and withIonLifeCycle() in @Ionic/react?

I’m trying to combine react-redux connect() and withIonLifeCycle() in @Ionic/react but no luck. I had to use Ionic React lifecycle hook instead for now.


Anyone can do this? Please give me some sample code.
Many thanks.

@mhartington, hope you can help :slight_smile:

I tried but not luck, for me this is a bug. I explain what I did.

withIonLifeCycle are a HOC so, this is same to use for example “withRouter”, when you use react-router-dom.

My code here ** export default connect( mapStateToProps, { myAction } )( withIonLifeCycle( MyComponent ) ) **
After this code life cycle methods should work but nothing happens, so, fo me, it is a bug.

Also I found more bugs, ion-menu are totally broken, update and work ones, the second don’t. This is a beta and have problems, or maybe is my operating system, I don’t know >﹏<

Hi @alextkd2003,
I got help from Payton.
This will work

export default withIonLifeCycle(connect(mapStateToProps, { myAction })(MyComponent))

The Redux store is then created in the main.jsx file of our Ionic React application.

Thanks @it.hieund

Does not work for me

export default withIonLifeCycle( connect( stateMapToProps, { fetchCategoriesAction } ) (Categories) );
Check the render method of Context.Consumer.
in ConnectFunction (created by Context.Consumer)
in IonLifeCycle (created by Context.Consumer)…

I saw you use hooks, Can you let me know where did you find documentation about Ionic Hooks, I can’t find it. Thanks

Here is the document:

1 Like

Thanks @it.hieund, with hooks works just fine :slight_smile:

@alextkd2003, you’re welcome :slight_smile: