Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with react-native-navigation #16

Closed
JimTeva opened this issue Jul 3, 2020 · 7 comments
Closed

Working with react-native-navigation #16

JimTeva opened this issue Jul 3, 2020 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@JimTeva
Copy link

JimTeva commented Jul 3, 2020

For anyone who needs to make this work with react-native-navigation, this is how I did:

Create a transparent screen (a full screen component) where you will display the notifier

import React, {Component} from 'react';
import {View} from 'react-native';
import {NotifierRoot} from 'react-native-notifier';
import {Navigation} from 'react-native-navigation';

export class Notifier extends Component {
  componentDidMount() {
    this.notifierRef.showNotification({
      title: this.props.textToShow,
      duration: 1000,
    });
    setTimeout(() => {
      Navigation.dismissOverlay(this.props.componentId);
    }, 1200);
  }
  render() {
    return (
      <View style={Styles.mainContainer}>
        <NotifierRoot
          ref={ref => {
            this.notifierRef = ref;
          }}
        />
      </View>
    );
  }
}

export default Notifier;

const Styles = {
  mainContainer: {
    height: 100,
    width: '100%',
    backgroundColor: 'transparent',
  },
};

Register that screen with react-native-navigation (I am using Redux and a gestureHandler in my example but this is not needed)

import Notifier from '../components/notifier';
...
Navigation.registerComponentWithRedux(
    'NotifierScreen',
    () => gestureHandlerRootHOC(Notifier),
    Provider,
    store,
  );

Now, anywhere in your app, show the notifier using Overlay

Navigation.showOverlay({
	component: {
		name: 'NotifierScreen',
		passProps: {
			textToShow: 'Success !',
		},
		options: {
			overlay: {
				interceptTouchOutside: false,
			},
			layout: {
				componentBackgroundColor: 'transparent',
			},
		},
	},
});
@seniv seniv added the documentation Improvements or additions to documentation label Jul 4, 2020
@seniv
Copy link
Owner

seniv commented Jul 4, 2020

Hey @JimTeva, thanks for the information!
I didn't try to use notifier with react-native-navigation, but this might be helpful and I'm going to add a link to this issue in Readme.

@JimTeva JimTeva closed this as completed Jul 5, 2020
@pke
Copy link

pke commented Nov 5, 2021

@JimTeva Why is this required in the first place? Did the notifications not show up? Did the screw up the rendering of the navigators?

@JimTeva
Copy link
Author

JimTeva commented Nov 5, 2021

@pke I don't know if this is still relevant as it has been more than a year now. For what I remember the notifier didn't show up while using react-native-navigation.

@pke
Copy link

pke commented Nov 10, 2021

I'll give it a try.

@z1haze
Copy link

z1haze commented Dec 6, 2023

@JimTeva Why is this required in the first place? Did the notifications not show up? Did the screw up the rendering of the navigators?

The issue is the z-index if you're using createNativeStackNavigator. The notifications appear beneath the screens

@JimTeva
Copy link
Author

JimTeva commented Dec 6, 2023

@z1haze Are you talking about React Native Navigation or React Navigation?

@z1haze
Copy link

z1haze commented Dec 6, 2023

Sorry, react-navigation. I'll update my post. There's a Readme todo about perhaps this issue, but it is hardly a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants