react-native-notifier
react-native-notifier copied to clipboard
Use context
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.
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} />
</>
);
}