Created
May 20, 2019 14:20
-
-
Save Bitaru/e8eea84b729346a4dd28969dd1cb6eed to your computer and use it in GitHub Desktop.
findify_with_react
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
import React from 'react'; | |
let _key = 1; | |
class FindifyComponent extends React.Component{ | |
widgetKey = void 0; | |
createFindifyComponent = (ref) => { | |
if (!ref || !!this.widgetKey) return; | |
const { type, config = {} } = this.props; | |
this.widgetKey = _key + 1; | |
window.findify.attach(ref, type, { ...config, widgetKey: this.widgetKey }); | |
} | |
componentWillUnmount() { | |
window.findify.detach(this.widgetKey) | |
} | |
render() { | |
return <div ref={this.createFindifyComponent} /> | |
} | |
} | |
// How to use => <FindifyComponent type='search' config={{ ... }}/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment