Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jbrundagejr
Regular Visitor

PowerBI with React Functional Components

Hello:

 

Building my second custom PBI visual, this time with React. I am using functional components and at a complete loss when it comes to getting the data from the update method into App.tsx. App.update({data: dataArray}) throws this error: ```Property 'update' does not exist on type 'FunctionComponent<AppProps```

 

This is how I have my visual.ts setup:

import {App, initialState} from './App'

 

constructor(options: VisualConstructorOptions) {
  this.reactRoot = React.createElement(App)
  this.target = options.element;
  ReactDOM.render(this.reactRoot, this.target)
}
 
public update(options: VisualUpdateOptions) {
 **does a bunch of reformating off incoming data, spitting out `dataObjectArray`
 App.update({data: dataObjectArray})
}
 
In App.tsx: 
export interface AppProps {
  data: dataObject[]
}

export const initialState: AppProps = {
  data: []
}

export const App: React.FC<AppProps> = () => {
 useEffect( setData(data)) but formatted properly obviously
 }
 
It would be great if Microsoft could update the guide to functional components instead of class based... Any help would be very much appreciated!! Thank you in advance.

 

3 REPLIES 3
jbrundagejr
Regular Visitor

Thank you for the reply! I've changed it around so I no longer get the TS complaints, but I still don't understand by my update method in visual.ts isn't passing the props to App.tsx. At the end of the update method, I pass in my props and call it like so: 

App({
  dataArr: dataObjectArray,
  height,
  width
})
this.update(options)
}
 
And my App is setup like so: 
export const App: React.FC<AppProps> = (props) => {
  const { dataArr, width, height } = props;
}
A console log in my App of dataArr, width and height all return undefined which I don't understand. Any insight as to how to get my data talking to my App.tsx (a functional component) from the visual.ts file would be greatly appreciated!!

@jbrundagejr would you be able to update react functional component custom visual.

 

Or any documentation you found for, how to update react functional component using power bi custom visual. As I am new to this and stuck. As not able to update react component.

 

Any help would be appreciated.

 

Thanks

v-yalanwu-msft
Community Support
Community Support

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.