Pendo with React SPA
Hi,
Looking at your SPA guide, we need to install the initialise after the user has logged in, but it needs to be run on every page.
Does this mean that we can install this snippet to any common component once the user is logged in, such as the menu bar?
Secondly, if we put this into a react file, there is no reference to import. How do we reference Pendo from within a react file or should we be doing something differently?
0
Comments
Did you every figure this out? In case some one else comes across this post. I had the same question and after hours of playing around I was able to get Pendo working with in a ReactJS SPA.
you need to include the common snippet in to your index.html, then add the `pendo.initialize` code in to a common component. (eg: component that loads after user logins)
The caveat here is you need to use `window.pendo.initialize` or else it will say that pendo is undefined.
I am having this same problem, but I can't seem to use window.pendo either, because Typescript doesn't understand that it exists.
For Typescript you need to create a definition file for pendo.
The following is not a Pendo Official library but has worked for me.
DefinitelyTyped/types/pendo-io-browser at master · DefinitelyTyped/DefinitelyTyped (github.com)
load Pendo script dynamically from the CDN using a custom function, then initialize Pendo after the user logged in.
This method works without using pendo-io-brower package.
src/pendo.d.ts (create a custom typing file to let TypeScript know about the global pendo object;
src/pendoUtils.ts (pendo utility functions)
In react component
Please sign in to leave a comment.