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

Use context #41

Open
nandorojo opened this issue Jul 23, 2021 · 1 comment
Open

Use context #41

nandorojo opened this issue Jul 23, 2021 · 1 comment
Labels
enhancement New feature or request pinned Pinned issues that should be resolved

Comments

@nandorojo
Copy link

Hey, I'm running into an issue where I want to use multiple notificationwrappers. one of them is nested inside of another screen. However, it seems that rather than use react context, this lib just uses a single wrapper at the root of the app and renders from there. The issue with this is that it renders under modals. I tried adding another wrapper inside the modal, but this did nothing, since it's not a context provider, which would take precedent over any parent providers.

@seniv
Copy link
Owner

seniv commented Jul 24, 2021

Hey, that makes sense to add the ability to control notifiers with context, I will implement this.
For now, you can render NotifierRoot with useRef and create your own context provider. Something like this:

import { NotifierRoot } from 'react-native-notifier';

const NotifierContext = React.createContext(null);

function App() {
  const notifierRef = useRef();
  return (
    <>
      <NotifierContext.Provider value={notifierRef}>
        <RootNavigator />
      </ NotifierContext.Provider>
      <NotifierRoot ref={notifierRef} />
    </>
  );
}

@seniv seniv added enhancement New feature or request pinned Pinned issues that should be resolved labels Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned Pinned issues that should be resolved
Projects
None yet
Development

No branches or pull requests

2 participants