<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: using powerbi-client with react in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/754474#M20177</link>
    <description>&lt;P&gt;This worked like a charm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;idk why this is not explicity in the documentation, thanks anyway.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 23:20:16 GMT</pubDate>
    <dc:creator>ReportesAM</dc:creator>
    <dc:date>2019-07-31T23:20:16Z</dc:date>
    <item>
      <title>using powerbi-client with react</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/302805#M8928</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Im new to Power BI and this forum but I am struggling to embed a report onto a web page using react js.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have npm installed the library&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;npm install --save powerbi-client&lt;/PRE&gt;&lt;P&gt;included the library at the top of my page&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import * as pbi from 'powerbi-client';&lt;/PRE&gt;&lt;P&gt;I can now see that there is an Embed method under the pbi&lt;/P&gt;&lt;PRE&gt;var config = {&lt;BR /&gt; type: 'report',&lt;BR /&gt; tokenType: models.TokenType.Embed,&lt;BR /&gt; accessToken: txtAccessToken,&lt;BR /&gt; embedUrl: txtEmbedUrl,&lt;BR /&gt; id: txtEmbedReportId,&lt;BR /&gt; permissions: permissions,&lt;BR /&gt; settings: {&lt;BR /&gt;   filterPaneEnabled: true,&lt;BR /&gt;   navContentPaneEnabled: true&lt;BR /&gt;   }&lt;BR /&gt; };&lt;BR /&gt;&lt;BR /&gt;pbi.Embed(/* Service */, /*Html Element */ ,config)&lt;/PRE&gt;&lt;P&gt;I can see that I need a service and to reference a HTML Element&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed to get a simple example working in plain JS from following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html" target="_blank"&gt;https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any documentation or an example on how this is called from react?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:51:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/302805#M8928</guid>
      <dc:creator>IanControlF1</dc:creator>
      <dc:date>2017-11-14T13:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: using powerbi-client with react</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/303466#M8940</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/46895"&gt;@IanControlF1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Im new to Power BI and this forum but I am struggling to embed a report onto a web page using react js.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have npm installed the library&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;npm install --save powerbi-client&lt;/PRE&gt;
&lt;P&gt;included the library at the top of my page&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import * as pbi from 'powerbi-client';&lt;/PRE&gt;
&lt;P&gt;I can now see that there is an Embed method under the pbi&lt;/P&gt;
&lt;PRE&gt;var config = {&lt;BR /&gt; type: 'report',&lt;BR /&gt; tokenType: models.TokenType.Embed,&lt;BR /&gt; accessToken: txtAccessToken,&lt;BR /&gt; embedUrl: txtEmbedUrl,&lt;BR /&gt; id: txtEmbedReportId,&lt;BR /&gt; permissions: permissions,&lt;BR /&gt; settings: {&lt;BR /&gt;   filterPaneEnabled: true,&lt;BR /&gt;   navContentPaneEnabled: true&lt;BR /&gt;   }&lt;BR /&gt; };&lt;BR /&gt;&lt;BR /&gt;pbi.Embed(/* Service */, /*Html Element */ ,config)&lt;/PRE&gt;
&lt;P&gt;I can see that I need a service and to reference a HTML Element&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have managed to get a simple example working in plain JS from following:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html" target="_blank"&gt;https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any documentation or an example on how this is called from react?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/46895"&gt;@IanControlF1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I don't know about react, however as per the response from the Power BI client author, you could reference the Angular sample, see &lt;A href="https://github.com/Microsoft/PowerBI-JavaScript/issues/225" target="_self"&gt;this&lt;/A&gt;. For further request, I'd suggest you post in that git lib.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 06:29:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/303466#M8940</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-11-15T06:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: using powerbi-client with react</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/303734#M8945</link>
      <description>&lt;P&gt;I am replying to myself as I think I have got closer and it might help others looking at this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6971"&gt;@Eric_Zhang&lt;/a&gt;&amp;nbsp;I looked at the Angular example yesterday and kinda reverse engineered in our example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem was that I was trying to call an abstract &lt;STRONG&gt;which was wrong&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;pbi.Embed(/* Service */, /*Html Element */ ,config)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end I did the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New up the powerBi Service:&lt;/P&gt;&lt;PRE&gt;let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);&lt;/PRE&gt;&lt;P&gt;and call it passing in the config&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Embed the report and display it within the div container.&lt;BR /&gt;var reportContainer = document.getElementById('reportContainer');&lt;BR /&gt;var report = powerbi.embed(reportContainer, config);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 11:10:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/303734#M8945</guid>
      <dc:creator>IanControlF1</dc:creator>
      <dc:date>2017-11-15T11:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: using powerbi-client with react</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/754474#M20177</link>
      <description>&lt;P&gt;This worked like a charm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;idk why this is not explicity in the documentation, thanks anyway.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 23:20:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/using-powerbi-client-with-react/m-p/754474#M20177</guid>
      <dc:creator>ReportesAM</dc:creator>
      <dc:date>2019-07-31T23:20:16Z</dc:date>
    </item>
  </channel>
</rss>

