Using React.useEffect() in my custom component

I am having trouble figuring out how to make my custom component reactive. I would like a function to run when the model is changed. Retool seems to obfuscate some of the React wiring, and not being very good at React yet, I am having trouble figuring out the right place to put things and how.

It seems like I want to utilize Effect Hooks to watch the model and trigger a function on change. But I can't for the life of me figure out where to put it. Or I may be barking up the wrong tree.

Any advice on how to trigger a function within my custom component when I change something in the model?

You might be missing the model subscription. There are three important functions with custom components (mentioned here), and the model subscription will trigger your code whenever the model changes. In this example, we log a value every time the value of our text input changes.

That does it!

Also, this makes me realize I don't have to use React in my custom components which takes a load off my mind and opens up more possibilities for making custom components!

1 Like