Skip to content

Instantly share code, notes, and snippets.

@agupta93
Created June 29, 2021 16:40
Show Gist options
  • Save agupta93/68314c16d022f60d60661f6b52500bfe to your computer and use it in GitHub Desktop.
Save agupta93/68314c16d022f60d60661f6b52500bfe to your computer and use it in GitHub Desktop.
mport React from 'react'
const withPusher = WrappedComponent => {
class WithPusher extends React {
subscribeToChannel() {
const channelName = getChannelName();
subscribeToChannel(channelName);
}
unSubscribeToChannel() {
const channelName = getChannelName();
unSubscribeToChannel(channelName);
}
componentDidMount() {
this.subscribeToChannel()
}
componentWillUnmount() {
this.unSubscribeToChannel()
}
render() {
return <RenderComponent {...props}/>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment