Hey there, I'm trying to hook an external (as it n...
# gooddata-ui
Hey there, I'm trying to hook an external (as it not as a
provided to a Dashboard) React component to a Dashboard in order to get its state (and more precisely the
part). I've managed to make it works using the Dashboard's props
but there's a remark in the method description: > @remarks > Note: there is no need to use this in your own React components that you plug into the dashboard. Your React component code can use @gooddata/sdk-ui-dashboard#useDashboardSelector and @gooddata/sdk-ui-dashboard#useDashboardDispatch hooks instead. I've tried to use both as the SDK implies, but as far as I can tell, I can only use
inside a
passed to a Dashboard because the method needs to access the Dashboard store. Now the questions are: 1. Is there any way to separate the store from the dashboard component so we can add React stuff in between? 2. Is there another way to properly get a dashboard state? 3. If not, the
is triggered a lot of time through a dashboard loading, so is there a cleaner way to get the
only once it's fully load or do I have to reset to check the layout existence in the
each time it's fired? 4. There's a
props in the Dashboard but as far I tried, it add a bar at the top of the dashboard. Considering I'm trying to bind the dashboard
to a vertical menu, would I be better to pass a React component to that props instead of trying to extract the state?
Hi Bastien, Radek from the GoodData technical team here! I've forwarded your questions to the SDK devs and will let you know once I get a response - not everyone is in over the holidays, but I'm hoping to have more for you soon 🙂
Hi Bastien, very sorry for the delay, I'm trying to get info from the devs still - unfortunately they have a lot on their plate 😞 Is your situation still the same, or have you managed to crack this? I'm assuming you're still using onStateChange in the meantime if not?
Hi Bastien, the devs would like to find out a little more details in order to be able to advise more effectively - specifically, what is the intended function of the custom widget here?
Hello, I've went around the problem by using a custom widget but I can give you some more details if it can help you or anyone struggling: 1. The goal was to create an interactive side bar for a dashboard containing a navigable list of section groups (we've made it so the side menu is able to group different sections under one category by using the content of the section's description), using the menu would only display the given group of sections within said dashboard a. Sidenote: the whole idea is probably not as good as we though as it leads to bigger dashboards 2. I first tried by hooking the parent React component to the dashboard onStateChange but the implementation was fragile and heavily relied on memoization and correct React dep to prevent unnecessary rerendering 3. I finally went around by creating a hidden section within the dashboard through customWidget to get the dashboard's layout and it's own state to prevent unnecessary rerendering, and portal the side bar somewhere up in the React tree when necessary
🙌 1