May 26, 2021 06:53 AM
I’ve built a custom app which has functionality to both use it in the sidebar or have it triggered when you press a button field. I’d like to force the app to reload any time the useRecordActionData hook detects a change. How would I go about pinning that kind of functionality to the hook?
I’m trying to reset all the various React states whenever there’s new info from the hook.
May 26, 2021 09:52 AM
regular ol’ useEffect()
could do it.
useEffect(() => {
setState(...)
}, [recordActionData.recordId])
May 26, 2021 10:20 AM
Brilliant. I’m new to React so I love learning some “goole 'ole” tricks. Thank you!
May 27, 2021 07:53 AM
I’m still having some trouble here. useEffect() is great for resetting the states, but it’s not helpful for resetting the UI after a second button click.
This is working:
What’s not working:
I realize this is because useEffect() runs its logic after the app renders. It seems like updates to useRecordActionData() don’t force the components to re-render.
How can I get updated data into the UI before a re-render every time the recordActionData is updated?