Created
March 18, 2019 08:32
-
-
Save koistya/32097558467589f049a2d7b2609a8754 to your computer and use it in GitHub Desktop.
Facebook Customer Chat React.js component https://medium.com/p/5b7c21343048
This file contains hidden or 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
import React from 'react'; | |
import { fb } from '../utils'; | |
import { ConfigContext } from '../hooks'; | |
class CustomerChat extends React.PureComponent { | |
componentDidMount() { | |
this.timeout = setTimeout(() => { | |
fb(FB => this.timeout && FB.XFBML.parse()); | |
}, 2000); | |
} | |
componentWillUnmount() { | |
clearTimeout(this.timeout); | |
delete this.timeout; | |
} | |
render() { | |
return ( | |
<ConfigContext.Consumer> | |
{config => ( | |
<div | |
className="fb-customerchat" | |
attribution="setup_tool" | |
page_id={config.facebook.pageId} | |
// theme_color="..." | |
// logged_in_greeting="..." | |
// logged_out_greeting="..." | |
// greeting_dialog_display="..." | |
// greeting_dialog_delay="..." | |
// minimized="false" | |
// ref="..." | |
/> | |
)} | |
</ConfigContext.Consumer> | |
); | |
} | |
} | |
export default CustomerChat; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment