schiehll / react-alert

alerts for React
MIT License
607 stars 98 forks source link

Many contexts in one component #178

Open CodeWithMichal opened 3 years ago

CodeWithMichal commented 3 years ago

Hi, I am having difficulty using more than one context in component. Say I have two contexts: -InfoContext -ErrorContext

I know what to do if I want to use only one of them, since its simply: export default withAlert(InfoContext)(App) or export default withAlert(ErrorContext)(App)

But how can I use both of them in component? I tried to pass both contexts, like: export default withAlert(InfoContext, ErrorContext)(App) however I stucked at this point. Any sugestions?

Best regards, Michał

besLisbeth commented 3 years ago

Hi @LabuzzMichal. Is the question still relevant? Did you try to double-wrap the component with the HOC (I'm not sure that is the best way of doing this sort of stuff)? export default withAlert(InfoContext)(withAlert(ErrorContext)(App))