How to selectively reload a component on the forge app

Hi,
Im passing the value from react component “A” to forge resolver, now we are performing operation on values and returning the updated value to react component “B”, but component “B” is not getting updated and not showing the updated value. So how to reload the component “B” after receiving the updated value.

How to refresh a particular component or div in a forge app.

2 Likes

Hi,
I take it, that you want to update the value of the checkbox?
If so, you can use the UI-kit hooks to update the Checkbox on change.
https://developer.atlassian.com/platform/forge/ui-kit-hooks-reference/

If you have a specific use case which the UI-kit hooks don’t cover, I think you need to elaborate further.

Regards
Adrian

Hi Adrian,

Thank you so much for the response, I have edited my question if u have the answer please revert back.

Hello,

if i understand correctly the useEffect() function will be a perfect fit.
First you have to define your component with useState(). And then update it with useEffect.

const [B, setB] = useState(null); //Here you can set the first Value of B. In this case im just setting it to null

useEffect(() => {
  setB(newValue); // useEffect will trigger on first page load and because A is defined below, useEffect will trigger if the Value of A gets updated. 
}, [A])

this is just an example. Try to read into it. The hooks useState and useEffect are very essential and good to learn.