Ability to inject context...
I need to utilize context in content of Notification. Can i retain the root component's context while using this component?
We are using Antd UI and MobX store, Apollo Graphql for React. The problem is in Notification content (component), we cannot access store or apollo client.. This might be not a usual case, but for some one who might land here, i leave a workaround.
import Notification from 'rc-notification';
const renderNotification = Notification.prototype.render;
Notification.prototype.render = function() {
return (
<ApolloProvider client={apolloClient}>
<StoreProvider store={store}>
{renderNotification.call(this)}
</StoreProvider>
</ApolloProvider>
)
}
By overriding Notification's render function, can access apollo or mobx in notification content.
Rc-notification may provide an option to utilize React portal to retain root component's context..
Hmm... How about add feature like this:
import notification from 'rc-notification';
const NotificationContainer = notification.Container;
notification.setConfig({
customContainer: true,
});
// ...
<ApolloProvider client={apolloClient}>
<StoreProvider store={store}>
<NotificationContainer />
</StoreProvider>
</ApolloProvider>
related https://github.com/ant-design/ant-design/issues/9036
Also looking for this functionality