I am trying to add Bootstrap 5 popovers in React. I am not using any React-Bootstrap library. Per the Bootstrap
CodePudding user response:
Both of these errors are related to restrictions of TypeScript. In order to solve the first error, I would suggest you use a for
loop instead of using map
like:
for (let i = 0; i < popoverTriggerList.length; i ) {
const popoverTriggerEl = popoverTriggerList[i];
new bootstrap.Popover(popoverTriggerEl);
}
In order to solve the second error, I would suggest you declare a bootstrap
variable like:
declare var bootstrap: any;
You can take a look at this sandbox (bootstrap included by cdn) or this sandbox (bootstrap included by npm) for a live working examples of these usages.