react-intercom
react-intercom copied to clipboard
fix: relay IntercomAPI secondary arguments (2.0)
Currently the secondary arguments of IntercomAPI
in 2.0
get passed through as an array, meaning that e.g. onShow
and onHide
won't work. I.e.
window.Intercom.apply(null, [method, args]);
Should be:
window.Intercom.apply(null, [method, ...args]);
However, with the above fix npm run build
throws an error:
Error: '__spreadArrays' is not exported by tslib
This may be solvable by updating the correct packages. Alternatively, the code can be written as it is in this pull request or something like:
export default function(method: string, ...args: Array<any>) {
if (window.Intercom) {
args.unshift(method);
window.Intercom.apply(null, args);
} else {
console.warn('Intercom not initialized yet');
}
}