robcalcroft / react-native-in-app-notification

:bell: Customisable in-app notification component for React Native
MIT License
270 stars 78 forks source link

Redux support #20

Open shiftrtech opened 5 years ago

shiftrtech commented 5 years ago

Hi, can you please show me an example of using react-native-in-app-notification with react-redux.

On your docs says:

export default withInAppNotification(MyApp);

But i need to use it on my Routes file (so i can routing on notification onPress event), i am using react-native-router-flux, so right now i have this on my Routes file:

export default connect(mapStateToProps)(Routes);

I think i can't consume the showNotification prop on that file.

Maybe if i use this approach can i make it?:

https://gist.github.com/testshallpass/d76c656874e417bef4e0e6a63fc492af

So not using the context and use the static class helper.

What do you think guys.

Thanks.

mikitasolo commented 5 years ago

@shiftrtech you can use something like export default connect( mapStateToProps, mapDispatchToProps )(withInAppNotification(Component))

sa2812 commented 4 years ago

@SobakaSlava - this works and lets you then use this.props.showNotification in the component. 👍

However, a further question on using this with Redux, is it possible to call the showNotification method outside of the context of a view (and just show it up wherever the user is?). An example is that a user might submit something and that gets fired off asynchronously. Meanwhile the might visit another page. In that time, I would like to notify them that their submission was successful (or not). How can this be achieved?