react-native-in-app-notification icon indicating copy to clipboard operation
react-native-in-app-notification copied to clipboard

Redux support

Open shiftrtech opened this issue 6 years ago • 2 comments

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.

shiftrtech avatar Nov 14 '18 18:11 shiftrtech

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

mikitasolo avatar Dec 05 '18 10:12 mikitasolo

@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?

sa2812 avatar Nov 20 '19 21:11 sa2812