Skip to content

Instantly share code, notes, and snippets.

@Bitaru
Created May 20, 2019 14:20
Show Gist options
  • Save Bitaru/e8eea84b729346a4dd28969dd1cb6eed to your computer and use it in GitHub Desktop.
Save Bitaru/e8eea84b729346a4dd28969dd1cb6eed to your computer and use it in GitHub Desktop.
findify_with_react
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