microsoft / powerbi-client-react

Power BI for React which provides components and services to enabling developers to easily embed Power BI reports into their applications.
MIT License
310 stars 98 forks source link

Embedding report not working in React Vite project. #109

Closed Hulsegge closed 5 months ago

Hulsegge commented 8 months ago

Hi,

I cloned the demo project and i achieved to show our own report in it. Next i installed the dependencies in our vite template:

  1. "powerbi-client-react": "^1.4.0",
  2. "powerbi-report-authoring": "^1.1",

I copied the DemoApp.jsx and the other files attached to it. I also added a console.log to the ReportConfig in both project the original demo and our own template. The output is exactly the same (in the end it's the same component running in another project.) However in my vite project i get all the time an error, but im really really sure the embedUrl etc is correct.:

image

I don't know if this has something to do with my project running yarn and vite ? Are there some limitations? this is how my vite.config.ts looks like:

/ eslint-disable import/no-extraneous-dependencies / /// ///

import react from '@vitejs/plugin-react-swc'; import path from 'path'; // Import path module for file paths import { defineConfig } from 'vite';

// https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ plugins: [react()], base: './', server: { port: 8080, }, preview: { port: 3000, }, test: { globals: true, environment: 'jsdom', setupFiles: './src/setupTests.ts', }, define: { 'process.env.APP_MODE': JSON.stringify(mode), }, }));

Hulsegge commented 8 months ago

ok i found it, it has nothing to do with VITE it is this tag

apparently it is blocking the execution or something, maybe a good idea to add this comment to the tutorials ?
paul-at-locus commented 8 months ago

The latest powerbi-client version 2.23.0 seems to have introduced this.

Downgrading to 2.22.4 seems to resolve this.

"powerbi-client": "2.22.4",
"powerbi-client-react": "^1.4.0",
Removable commented 7 months ago

I updated the "powerbi-client" (not "powerbi-client-react") to version 2.23.1, and then the problem was gone!

refer: https://github.com/microsoft/powerbi-client-react/issues/94#issuecomment-2029614741

KotanaSai21 commented 7 months ago

@Hulsegge ,

The issue you're facing is with the powerbi-client package and it is fixed with the latest version. We shouldn't face any issues with Embedding report even in the React Strict mode. Let us know if you still have any queries.