Created
June 29, 2021 16:40
-
-
Save agupta93/68314c16d022f60d60661f6b52500bfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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