Embed a Power BI report in React JS to get report instance

I am trying to embed a Power BI report in React JS and I would like to embed the report and get the report instance to work further with it. I am using Power BI react extension in react to embed the report but I keep getting an error that Cannot read property ’embed’ of undefined.


import { powerbi, models, embed } from "powerbi-client";
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";

function ReportBI() {
  let token ="abcExample";
  let embedUrlBi = "https://app.powerbi.com/reportEmbed";
  let reportId = "ReportID";
  const embedConfig = {
    type: "report",
    id: reportId,
    embedUrl: embedUrlBi,
    accessToken: token,
    tokenType: models.TokenType.Embed

  function test() {
    var embedContainer = document.getElementById("container");
    var report = powerbi.embed(embedContainer, embedConfig);
  useEffect(() => {
  return (
      <div id="container"></div>

const element = <ReportBI />;

ReactDOM.render(element, document.getElementById("root"));


<div id="root">
      <div id="container"></div>

I am trying to get instance of the report after embedding it to do other things with it. Can I do this?


You may try the new powerbi-client-react library for embedding PowerBI entities in React applications

The “getEmbeddedComponent” prop returns the instance of embedded PowerBI report