1

I have a requirement where i need to get the property of one SPFX webpart and based on that need to display another one webpart. Is there any way to get the props of the webpart during load itself.

I tried the dynamic-data method but it works only when some event occurs after the webpart loads. But what i need is to get during component load itself.

I tried adding the notify in the render of webpart but its not working.

Is there any way to emit the property and get that value during webpart part load itself.

Thanks in Advance. Regards, Siva.

2 Answers 2

0

This can be achieved using "@microsoft/sp-dynamic-data". You will have to declare the property as dynamic in your sender web part and then access it in your receiver web part property pane. Check the code in below link:

https://ravichandran.blog/2020/06/12/send-and-receive-values-between-two-spfx-webparts/

1
  • Thank you for the response SiD , I tried the link specified and it works when there is an event happens and not during webpart loading. After the source webpart loads if some event happens then its successfully sending data but not during load itself.
    – Siva
    Feb 6, 2023 at 12:42
-1

Consider using URL parameters to pass the required value from one web part to another. Using window.history.pushState the first web part can create the URL parameter with the appropriate value and your second web part can then read that value from the parameter when it loads.

Appending parameter to URL without refresh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.